summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-06-12 15:12:31 +0800
committerDavid Sterba <dsterba@suse.cz>2014-08-22 14:39:34 +0200
commit0ca416890cf574194b115b8b2bcc287ed89675ae (patch)
treee2a3adce26016b56263fc8c701443216ecca6de8
parent3a3e6095412fc21843e43284d1b5ee71ff136d24 (diff)
btrfs-progs: Add human readable flags output string for extent flags.
Current btrfs-debug-tree outputs extent flags as numbers, which makes it hard to understand and need to check the source to understand the meaning. This patch will convert numberic flags output to human readable strings. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--print-tree.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/print-tree.c b/print-tree.c
index cb5c2e13..268abb58 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -251,6 +251,24 @@ static void print_file_extent_item(struct extent_buffer *eb,
btrfs_file_extent_compression(eb, fi));
}
+/* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */
+static void extent_flags_to_str(u64 flags, char *ret)
+{
+ int empty = 1;
+
+ if (flags & BTRFS_EXTENT_FLAG_DATA) {
+ empty = 0;
+ strcpy(ret, "DATA");
+ }
+ if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
+ if (!empty) {
+ empty = 0;
+ strcat(ret, "|");
+ }
+ strcat(ret, "TREE_BLOCK");
+ }
+}
+
void print_extent_item(struct extent_buffer *eb, int slot, int metadata)
{
struct btrfs_extent_item *ei;
@@ -264,6 +282,7 @@ void print_extent_item(struct extent_buffer *eb, int slot, int metadata)
u32 item_size = btrfs_item_size_nr(eb, slot);
u64 flags;
u64 offset;
+ char flags_str[32] = {0};
if (item_size < sizeof(*ei)) {
#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
@@ -280,11 +299,12 @@ void print_extent_item(struct extent_buffer *eb, int slot, int metadata)
ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
flags = btrfs_extent_flags(eb, ei);
+ extent_flags_to_str(flags, flags_str);
- printf("\t\textent refs %llu gen %llu flags %llu\n",
+ printf("\t\textent refs %llu gen %llu flags %s\n",
(unsigned long long)btrfs_extent_refs(eb, ei),
(unsigned long long)btrfs_extent_generation(eb, ei),
- (unsigned long long)flags);
+ flags_str);
if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK && !metadata) {
struct btrfs_tree_block_info *info;