+ char buf[12];
+ int sz;
+
+ sz = larr->arr_hai.hai_len - sizeof(larr->arr_hai);
+ printf("lrh=[type=%X len=%d idx=%d] fid="DFID
+ " compound/cookie=%#jx/%#jx"
+ " status=%s action=%s archive#=%d flags=%#jx"
+ " create=%ju change=%ju"
+ " extent=%#jx-%#jx gid=%#jx datalen=%d"
+ " data=[%s]\n",
+ larr->arr_hdr.lrh_type,
+ larr->arr_hdr.lrh_len, larr->arr_hdr.lrh_index,
+ PFID(&larr->arr_hai.hai_fid),
+ (uintmax_t)larr->arr_compound_id,
+ (uintmax_t)larr->arr_hai.hai_cookie,
+ agent_req_status2name(larr->arr_status),
+ hsm_copytool_action2name(larr->arr_hai.hai_action),
+ larr->arr_archive_id,
+ (uintmax_t)larr->arr_flags,
+ (uintmax_t)larr->arr_req_create,
+ (uintmax_t)larr->arr_req_change,
+ (uintmax_t)larr->arr_hai.hai_extent.offset,
+ (uintmax_t)larr->arr_hai.hai_extent.length,
+ (uintmax_t)larr->arr_hai.hai_gid, sz,
+ hai_dump_data_field(&larr->arr_hai, buf, sizeof(buf)));
+}
+
+void print_changelog_rec(struct llog_changelog_rec *rec)
+{
+ time_t secs;
+ struct tm ts;
+
+ secs = __le64_to_cpu(rec->cr.cr_time) >> 30;
+ gmtime_r(&secs, &ts);
+ printf("changelog record id:0x%x index:%llu cr_flags:0x%x "
+ "cr_type:%s(0x%x) date:'%02d:%02d:%02d.%09d %04d.%02d.%02d' "
+ "target:"DFID, __le32_to_cpu(rec->cr_hdr.lrh_id),
+ __le64_to_cpu(rec->cr.cr_index),
+ __le32_to_cpu(rec->cr.cr_flags),
+ changelog_type2str(__le32_to_cpu(rec->cr.cr_type)),
+ __le32_to_cpu(rec->cr.cr_type),
+ ts.tm_hour, ts.tm_min, ts.tm_sec,
+ (int)(__le64_to_cpu(rec->cr.cr_time) & ((1 << 30) - 1)),
+ ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday,
+ PFID(&rec->cr.cr_tfid));
+
+ if (rec->cr.cr_flags & CLF_JOBID) {
+ struct changelog_ext_jobid *jid =
+ changelog_rec_jobid(&rec->cr);
+
+ if (jid->cr_jobid[0] != '\0')
+ printf(" jobid:%s", jid->cr_jobid);
+ }
+
+ if (rec->cr.cr_flags & CLF_EXTRA_FLAGS) {
+ struct changelog_ext_extra_flags *ef =
+ changelog_rec_extra_flags(&rec->cr);
+
+ printf(" cr_extra_flags:0x%llx",
+ __le64_to_cpu(ef->cr_extra_flags));
+
+ if (ef->cr_extra_flags & CLFE_UIDGID) {
+ struct changelog_ext_uidgid *uidgid =
+ changelog_rec_uidgid(&rec->cr);
+
+ printf(" user:%u:%u",
+ __le32_to_cpu(uidgid->cr_uid),
+ __le32_to_cpu(uidgid->cr_gid));
+ }
+ if (ef->cr_extra_flags & CLFE_NID) {
+ struct changelog_ext_nid *nid =
+ changelog_rec_nid(&rec->cr);
+
+ printf(" nid:%s",
+ libcfs_nid2str(nid->cr_nid));
+ }
+
+ if (ef->cr_extra_flags & CLFE_OPEN) {
+ struct changelog_ext_openmode *omd =
+ changelog_rec_openmode(&rec->cr);
+ char mode[] = "---";
+
+ /* exec mode must be exclusive */
+ if (__le32_to_cpu(omd->cr_openflags) & MDS_FMODE_EXEC) {
+ mode[2] = 'x';
+ } else {
+ if (__le32_to_cpu(omd->cr_openflags) &
+ MDS_FMODE_READ)
+ mode[0] = 'r';
+ if (__le32_to_cpu(omd->cr_openflags) &
+ (MDS_FMODE_WRITE | MDS_OPEN_TRUNC | MDS_OPEN_APPEND))
+ mode[1] = 'w';
+ }
+
+ if (strcmp(mode, "---") != 0)
+ printf(" mode:%s", mode);
+
+ }
+
+ if (ef->cr_extra_flags & CLFE_XATTR) {
+ struct changelog_ext_xattr *xattr =
+ changelog_rec_xattr(&rec->cr);
+
+ if (xattr->cr_xattr[0] != '\0')
+ printf(" xattr:%s", xattr->cr_xattr);
+ }
+ }
+
+ if (rec->cr.cr_namelen)
+ printf(" parent:"DFID" name:%.*s", PFID(&rec->cr.cr_pfid),
+ __le32_to_cpu(rec->cr.cr_namelen),
+ changelog_rec_name(&rec->cr));
+
+ if (rec->cr.cr_flags & CLF_RENAME) {
+ struct changelog_ext_rename *rnm =
+ changelog_rec_rename(&rec->cr);
+
+ if (!fid_is_zero(&rnm->cr_sfid))
+ printf(" source_fid:"DFID" source_parent_fid:"DFID
+ " %.*s",
+ PFID(&rnm->cr_sfid),
+ PFID(&rnm->cr_spfid),
+ (int)__le32_to_cpu(
+ changelog_rec_snamelen(&rec->cr)),
+ changelog_rec_sname(&rec->cr));
+ }
+ printf("\n");