Whamcloud - gitweb
LU-10378 utils: add formatted printf to lfs find
[fs/lustre-release.git] / lustre / utils / llog_reader.c
index 24903c8..b03d5df 100644 (file)
@@ -778,9 +778,9 @@ void print_changelog_rec(struct llog_changelog_rec *rec)
 
 static void lustre_swab_lu_fid(struct lu_fid *fid)
 {
-       __swab64s(&fid->f_seq);
-       __swab32s(&fid->f_oid);
-       __swab32s(&fid->f_ver);
+       fid->f_seq = __swab64(fid->f_seq);
+       fid->f_oid = __swab32(fid->f_oid);
+       fid->f_ver = __swab32(fid->f_ver);
 }
 
 static inline size_t
@@ -808,10 +808,10 @@ static void lustre_swab_update_ops(struct update_ops *uops,
 
        for (i = 0; i < op_count; i++, op = update_op_next_op(op)) {
                lustre_swab_lu_fid(&op->uop_fid);
-               __swab16s(&op->uop_type);
-               __swab16s(&op->uop_param_count);
+               op->uop_type = __swab16(op->uop_type);
+               op->uop_param_count = __swab16(op->uop_param_count);
                for (j = 0; j < op->uop_param_count; j++)
-                       __swab16s(&op->uop_params_off[j]);
+                       op->uop_params_off[j] = __swab16(op->uop_params_off[j]);
        }
 }
 static const char *update_op_str(__u16 opc)
@@ -886,8 +886,8 @@ void print_update_rec(struct llog_update_record *lur)
        up_count = __le32_to_cpu(rec->ur_update_count);
        pm_count = __le32_to_cpu(rec->ur_param_count);
        printf("updatelog record master_transno:%llu batchid:%llu flags:0x%x u_index:%d u_count:%d p_count:%d\n",
-              __le64_to_cpu(rec->ur_master_transno),
-              __le64_to_cpu(rec->ur_batchid),
+              (unsigned long long)__le64_to_cpu(rec->ur_master_transno),
+              (unsigned long long)__le64_to_cpu(rec->ur_batchid),
               __le32_to_cpu(rec->ur_flags),
               __le32_to_cpu(rec->ur_index),
               up_count,
@@ -916,6 +916,48 @@ void print_update_rec(struct llog_update_record *lur)
 
 }
 
+static void print_unlink_rec(struct llog_unlink_rec *lur)
+{
+       printf("unlink record id:0x%x target %llx:%x:%x\n",
+               __le32_to_cpu(lur->lur_hdr.lrh_id),
+               __le64_to_cpu(lur->lur_oid),
+               __le32_to_cpu(lur->lur_oseq),
+               __le32_to_cpu(lur->lur_count));
+}
+
+static void print_unlink64_rec(struct llog_unlink64_rec *lur)
+{
+       printf("unlink64 record id:0x%x target "DFID"\n",
+               __le32_to_cpu(lur->lur_hdr.lrh_id),
+               PFID(&lur->lur_fid));
+}
+
+static void print_setattr64_rec(struct llog_setattr64_rec *lsr)
+{
+       printf("setattr64 record id:0x%x target "DFID" valid %llx uid %u:%u gid %u:%u\n",
+               __le32_to_cpu(lsr->lsr_hdr.lrh_id),
+               PFID(&lsr->lsr_oi.oi_fid),
+               __le64_to_cpu(lsr->lsr_valid),
+               __le32_to_cpu(lsr->lsr_uid_h),
+               __le32_to_cpu(lsr->lsr_uid),
+               __le32_to_cpu(lsr->lsr_gid_h),
+               __le32_to_cpu(lsr->lsr_gid));
+}
+
+static void print_setattr64_rec_v2(struct llog_setattr64_rec_v2 *lsr)
+{
+       printf("setattr64 v2 record id:0x%x target "DFID" valid %llx uid %u:%u gid %u:%u prj %u\n",
+               __le32_to_cpu(lsr->lsr_hdr.lrh_id),
+               PFID(&lsr->lsr_oi.oi_fid),
+               __le64_to_cpu(lsr->lsr_valid),
+               __le32_to_cpu(lsr->lsr_uid_h),
+               __le32_to_cpu(lsr->lsr_uid),
+               __le32_to_cpu(lsr->lsr_gid_h),
+               __le32_to_cpu(lsr->lsr_gid),
+               __le32_to_cpu(lsr->lsr_projid));
+}
+
+
 static void print_records(struct llog_rec_hdr **recs,
                          int rec_number, int is_ext)
 {
@@ -958,12 +1000,29 @@ static void print_records(struct llog_rec_hdr **recs,
                                            recs[i]);
                        break;
                case CHANGELOG_USER_REC:
+               case CHANGELOG_USER_REC2:
                        printf("changelog_user record id:0x%x\n",
                               __le32_to_cpu(recs[i]->lrh_id));
                        break;
                case UPDATE_REC:
                        print_update_rec((struct llog_update_record *)recs[i]);
                        break;
+               case MDS_UNLINK_REC:
+                       print_unlink_rec((struct llog_unlink_rec *)recs[i]);
+                       break;
+               case MDS_UNLINK64_REC:
+                       print_unlink64_rec((struct llog_unlink64_rec *)recs[i]);
+                       break;
+               case MDS_SETATTR64_REC:
+                       if (__le32_to_cpu(recs[i]->lrh_len) >
+                               sizeof(struct llog_setattr64_rec)) {
+                               print_setattr64_rec_v2(
+                                 (struct llog_setattr64_rec_v2 *)recs[i]);
+                       } else {
+                               print_setattr64_rec(
+                                       (struct llog_setattr64_rec *)recs[i]);
+                       }
+                       break;
                default:
                        printf("unknown type %x\n", lopt);
                        break;