diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2016-10-10 10:12:22 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-10-24 14:58:02 +0200 |
commit | 5bd4016363d117f731caa044a444f2769b694f5c (patch) | |
tree | 415f5cd689e013611d3adaea610a404481262b48 | |
parent | e93f3e7ded0e9f22c8dc0fc70d8512f0fae013e5 (diff) |
btrfs-progs: Make btrfs-debug-tree print all readable strings for inode flags
Before this patch, only 3 inode flags have readable string: NODATACOW,
NODATASUM, READONLY.
This patch will output all readable strings for remaining inode flags,
making debug-tree tool more handy.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | print-tree.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/print-tree.c b/print-tree.c index 4444a143..29fe05c1 100644 --- a/print-tree.c +++ b/print-tree.c @@ -851,29 +851,36 @@ static void print_uuid_item(struct extent_buffer *l, unsigned long offset, } } -/* Caller should ensure sizeof(*ret) >= 29 "NODATASUM|NODATACOW|READONLY" */ +/* Btrfs inode flag stringification helper */ +#define STRCAT_ONE_INODE_FLAG(flags, name, empty, dst) ({ \ + if (flags & BTRFS_INODE_##name) { \ + if (!empty) \ + strcat(dst, "|"); \ + strcat(dst, #name); \ + empty = 0; \ + } \ +}) + +/* + * Caller should ensure sizeof(*ret) >= 102: all charactors plus '|' of + * BTRFS_INODE_* flags + */ static void inode_flags_to_str(u64 flags, char *ret) { int empty = 1; - if (flags & BTRFS_INODE_NODATASUM) { - empty = 0; - strcpy(ret, "NODATASUM"); - } - if (flags & BTRFS_INODE_NODATACOW) { - if (!empty) { - empty = 0; - strcat(ret, "|"); - } - strcat(ret, "NODATACOW"); - } - if (flags & BTRFS_INODE_READONLY) { - if (!empty) { - empty = 0; - strcat(ret, "|"); - } - strcat(ret, "READONLY"); - } + STRCAT_ONE_INODE_FLAG(flags, NODATASUM, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, NODATACOW, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, READONLY, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, NOCOMPRESS, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, PREALLOC, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, SYNC, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, IMMUTABLE, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, APPEND, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, NODUMP, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, NOATIME, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, DIRSYNC, empty, ret); + STRCAT_ONE_INODE_FLAG(flags, COMPRESS, empty, ret); if (empty) strcat(ret, "none"); } @@ -902,7 +909,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) u32 nr = btrfs_header_nritems(l); u64 objectid; u32 type; - char flags_str[32]; + char flags_str[256]; printf("leaf %llu items %d free space %d generation %llu owner %llu\n", (unsigned long long)btrfs_header_bytenr(l), nr, |