btrfs-progs: debug-tree: teach -t option about the chunk and root trees
authorDavid Sterba <dsterba@suse.com>
Wed, 13 Jan 2016 15:05:56 +0000 (16:05 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 13 Jan 2016 15:43:48 +0000 (16:43 +0100)
A user on IRC wanted to dump the chunk tree using the -t option. As the
-t option enumerates only trees pointed by the tree_root, the chunk tree
is skipped. Similar for th tree of tree roots.

Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-debug-tree.c

index 72dd787..05f9a81 100644 (file)
@@ -263,6 +263,29 @@ again:
        if (!extent_buffer_uptodate(tree_root_scan->node))
                goto no_node;
 
+       /*
+        * Tree's that are not pointed by the tree of tree roots
+        */
+       if (tree_id && tree_id == BTRFS_ROOT_TREE_OBJECTID) {
+               if (!info->tree_root) {
+                       error("cannot print root tree, invalid pointer");
+                       goto no_node;
+               }
+               printf("root tree\n");
+               btrfs_print_tree(info->tree_root, info->tree_root->node, 1);
+               goto no_node;
+       }
+
+       if (tree_id && tree_id == BTRFS_CHUNK_TREE_OBJECTID) {
+               if (!info->chunk_root) {
+                       error("cannot print chunk tree, invalid pointer");
+                       goto no_node;
+               }
+               printf("chunk tree\n");
+               btrfs_print_tree(info->chunk_root, info->chunk_root->node, 1);
+               goto no_node;
+       }
+
        key.offset = 0;
        key.objectid = 0;
        btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);