From 9ae2b8b52fe18efc0aab16ac3a5d1286a495b347 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Mon, 11 May 2015 16:08:44 +0800 Subject: [PATCH] btrfs-progs: show-super: print human readable text for super flags Use the new __print_readable_flag() to implement print_readable_super_flag(). Signed-off-by: Qu Wenruo [removed the chunk tree flag] Signed-off-by: David Sterba --- btrfs-show-super.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/btrfs-show-super.c b/btrfs-show-super.c index 430ddfe4..27414c88 100644 --- a/btrfs-show-super.c +++ b/btrfs-show-super.c @@ -305,6 +305,28 @@ struct readable_flag_entry incompat_flags_array[] = { static const int incompat_flags_num = sizeof(incompat_flags_array) / sizeof(struct readable_flag_entry); +#define DEF_HEADER_FLAG_ENTRY(bit_name) \ + {BTRFS_HEADER_FLAG_##bit_name, #bit_name} +#define DEF_SUPER_FLAG_ENTRY(bit_name) \ + {BTRFS_SUPER_FLAG_##bit_name, #bit_name} + +struct readable_flag_entry super_flags_array[] = { + DEF_HEADER_FLAG_ENTRY(WRITTEN), + DEF_HEADER_FLAG_ENTRY(RELOC), + DEF_SUPER_FLAG_ENTRY(CHANGING_FSID), + DEF_SUPER_FLAG_ENTRY(SEEDING), + DEF_SUPER_FLAG_ENTRY(METADUMP), + DEF_SUPER_FLAG_ENTRY(METADUMP_V2) +}; +static const int super_flags_num = ARRAY_SIZE(super_flags_array); + +#define BTRFS_SUPER_FLAG_SUPP (BTRFS_HEADER_FLAG_WRITTEN |\ + BTRFS_HEADER_FLAG_RELOC |\ + BTRFS_SUPER_FLAG_CHANGING_FSID |\ + BTRFS_SUPER_FLAG_SEEDING |\ + BTRFS_SUPER_FLAG_METADUMP |\ + BTRFS_SUPER_FLAG_METADUMP_V2) + static void __print_readable_flag(u64 flag, struct readable_flag_entry *array, int array_size, u64 supported_flags) { @@ -343,6 +365,12 @@ static void print_readable_incompat_flag(u64 flag) BTRFS_FEATURE_INCOMPAT_SUPP); } +static void print_readable_super_flag(u64 flag) +{ + return __print_readable_flag(flag, super_flags_array, + super_flags_num, BTRFS_SUPER_FLAG_SUPP); +} + static void dump_superblock(struct btrfs_super_block *sb, int full) { int i; @@ -362,6 +390,7 @@ static void dump_superblock(struct btrfs_super_block *sb, int full) (unsigned long long)btrfs_super_bytenr(sb)); printf("flags\t\t\t0x%llx\n", (unsigned long long)btrfs_super_flags(sb)); + print_readable_super_flag(btrfs_super_flags(sb)); printf("magic\t\t\t"); s = (char *) &sb->magic;