diff mbox series

[f2fs-dev,4/6] f2fs-tools: add DISP_u8() macro

Message ID 20230505100205.1921708-4-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev,1/6] f2fs-tools: add packed attribute for struct f2fs_super_block | expand

Commit Message

Chao Yu May 5, 2023, 10:02 a.m. UTC
Introduce DISP_u8(), and use DISP_u16() and DISP_u8() to print below fields:
- i_compress_algorithm
- i_log_cluster_size
- i_compress_flag

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c      |  6 +++---
 include/f2fs_fs.h | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fsck/mount.c b/fsck/mount.c
index b314756..5e475a3 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -302,9 +302,9 @@  void print_inode_info(struct f2fs_sb_info *sbi,
 		}
 		if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
 			DISP_u64(inode, i_compr_blocks);
-			DISP_u32(inode, i_compress_algorithm);
-			DISP_u32(inode, i_log_cluster_size);
-			DISP_u32(inode, i_compress_flag);
+			DISP_u8(inode, i_compress_algorithm);
+			DISP_u8(inode, i_log_cluster_size);
+			DISP_u16(inode, i_compress_flag);
 		}
 	}
 
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index dca4cd8..e5d5d13 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -282,6 +282,17 @@  static inline uint64_t bswap_64(uint64_t val)
 		printf("%-30s" fmt, #member, ((ptr)->member));	\
 	} while (0)
 
+#define DISP_u8(ptr, member)						\
+	do {								\
+		assert(sizeof((ptr)->member) == 1);			\
+		if (c.layout)						\
+			printf("%-30s %u\n",				\
+			#member":", ((ptr)->member));			\
+		else							\
+			printf("%-30s" "\t\t[0x%8x : %u]\n",		\
+			#member, ((ptr)->member), ((ptr)->member));	\
+	} while (0)
+
 #define DISP_u16(ptr, member)						\
 	do {								\
 		assert(sizeof((ptr)->member) == 2);			\