summaryrefslogtreecommitdiff
path: root/btrfs-show-super.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2015-05-11 16:08:43 +0800
committerDavid Sterba <dsterba@suse.cz>2015-05-14 15:41:07 +0200
commitb8436121c271a09e1abb01870c9ef11c2cc5c519 (patch)
tree8ae6b8f4b72982aa3556b9714a4526eecae59985 /btrfs-show-super.c
parent7cc792872a133cabc3467e6ccaf5a2c8ea9e5218 (diff)
btrfs-progs: Use unified function to implement print_readable_*_flag function
Now add a new unified __print_readable_flag() function to implement print_readable_incompat_flag(). This makes later extension for human readable flags easier. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'btrfs-show-super.c')
-rw-r--r--btrfs-show-super.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index 1c7a0867..430ddfe4 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -305,7 +305,8 @@ struct readable_flag_entry incompat_flags_array[] = {
static const int incompat_flags_num = sizeof(incompat_flags_array) /
sizeof(struct readable_flag_entry);
-static void print_readable_incompat_flag(u64 flag)
+static void __print_readable_flag(u64 flag, struct readable_flag_entry *array,
+ int array_size, u64 supported_flags)
{
int i;
int first = 1;
@@ -313,9 +314,10 @@ static void print_readable_incompat_flag(u64 flag)
if (!flag)
return;
+
printf("\t\t\t( ");
- for (i = 0; i < incompat_flags_num; i++) {
- entry = incompat_flags_array + i;
+ for (i = 0; i < array_size; i++) {
+ entry = array + i;
if (flag & entry->bit) {
if (first)
printf("%s ", entry->output);
@@ -324,7 +326,7 @@ static void print_readable_incompat_flag(u64 flag)
first = 0;
}
}
- flag &= ~BTRFS_FEATURE_INCOMPAT_SUPP;
+ flag &= ~supported_flags;
if (flag) {
if (first)
printf("unknown flag: 0x%llx ", flag);
@@ -334,6 +336,13 @@ static void print_readable_incompat_flag(u64 flag)
printf(")\n");
}
+static void print_readable_incompat_flag(u64 flag)
+{
+ return __print_readable_flag(flag, incompat_flags_array,
+ incompat_flags_num,
+ BTRFS_FEATURE_INCOMPAT_SUPP);
+}
+
static void dump_superblock(struct btrfs_super_block *sb, int full)
{
int i;