- if (!(extent_only || uuid_tree_only)) {
- if (roots_only) {
- printf("root tree: %llu level %d\n",
- (unsigned long long)info->tree_root->node->start,
- btrfs_header_level(info->tree_root->node));
- printf("chunk tree: %llu level %d\n",
- (unsigned long long)info->chunk_root->node->start,
- btrfs_header_level(info->chunk_root->node));
- } else {
- if (info->tree_root->node) {
- printf("root tree\n");
- btrfs_print_tree(info->tree_root,
- info->tree_root->node, 1);
- }
-
- if (info->chunk_root->node) {
- printf("chunk tree\n");
- btrfs_print_tree(info->chunk_root,
- info->chunk_root->node, 1);
- }
- }
- }
- tree_root_scan = info->tree_root;
-
- btrfs_init_path(&path);
-again:
- if (!extent_buffer_uptodate(tree_root_scan->node))
- goto no_node;
-
- key.offset = 0;
- key.objectid = 0;
- btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
- ret = btrfs_search_slot(NULL, tree_root_scan, &key, &path, 0, 0);
- BUG_ON(ret < 0);
- while(1) {
- leaf = path.nodes[0];
- slot = path.slots[0];
- if (slot >= btrfs_header_nritems(leaf)) {
- ret = btrfs_next_leaf(tree_root_scan, &path);
- if (ret != 0)
- break;
- leaf = path.nodes[0];
- slot = path.slots[0];
- }
- btrfs_item_key(leaf, &disk_key, path.slots[0]);
- btrfs_disk_key_to_cpu(&found_key, &disk_key);
- if (btrfs_key_type(&found_key) == BTRFS_ROOT_ITEM_KEY) {
- unsigned long offset;
- struct extent_buffer *buf;
- int skip = extent_only | device_only | uuid_tree_only;
-
- offset = btrfs_item_ptr_offset(leaf, slot);
- read_extent_buffer(leaf, &ri, offset, sizeof(ri));
- buf = read_tree_block(tree_root_scan,
- btrfs_root_bytenr(&ri),
- btrfs_level_size(tree_root_scan,
- btrfs_root_level(&ri)),
- 0);
- if (!extent_buffer_uptodate(buf))
- goto next;
-
- switch(found_key.objectid) {
- case BTRFS_ROOT_TREE_OBJECTID:
- if (!skip)
- printf("root");
- break;
- case BTRFS_EXTENT_TREE_OBJECTID:
- if (!device_only && !uuid_tree_only)
- skip = 0;
- if (!skip)
- printf("extent");
- break;
- case BTRFS_CHUNK_TREE_OBJECTID:
- if (!skip) {
- printf("chunk");
- }
- break;
- case BTRFS_DEV_TREE_OBJECTID:
- if (!uuid_tree_only)
- skip = 0;
- if (!skip)
- printf("device");
- break;
- case BTRFS_FS_TREE_OBJECTID:
- if (!skip) {
- printf("fs");
- }
- break;
- case BTRFS_ROOT_TREE_DIR_OBJECTID:
- skip = 0;
- printf("directory");
- break;
- case BTRFS_CSUM_TREE_OBJECTID:
- if (!skip) {
- printf("checksum");
- }
- break;
- case BTRFS_ORPHAN_OBJECTID:
- if (!skip) {
- printf("orphan");
- }
- break;
- case BTRFS_TREE_LOG_OBJECTID:
- if (!skip) {
- printf("log");
- }
- break;
- case BTRFS_TREE_LOG_FIXUP_OBJECTID:
- if (!skip) {
- printf("log fixup");
- }
- break;
- case BTRFS_TREE_RELOC_OBJECTID:
- if (!skip) {
- printf("reloc");
- }
- break;
- case BTRFS_DATA_RELOC_TREE_OBJECTID:
- if (!skip) {
- printf("data reloc");
- }
- break;
- case BTRFS_EXTENT_CSUM_OBJECTID:
- if (!skip) {
- printf("extent checksum");
- }
- break;
- case BTRFS_QUOTA_TREE_OBJECTID:
- if (!skip) {
- printf("quota");
- }
- break;
- case BTRFS_UUID_TREE_OBJECTID:
- if (!extent_only && !device_only)
- skip = 0;
- if (!skip)
- printf("uuid");
- break;
- case BTRFS_MULTIPLE_OBJECTIDS:
- if (!skip) {
- printf("multiple");
- }
- break;
- default:
- if (!skip) {
- printf("file");
- }
- }
- if (extent_only && !skip) {
- print_extents(tree_root_scan, buf);
- } else if (!skip) {
- printf(" tree ");
- btrfs_print_key(&disk_key);
- if (roots_only) {
- printf(" %llu level %d\n",
- (unsigned long long)buf->start,
- btrfs_header_level(buf));
- } else {
- printf(" \n");
- btrfs_print_tree(tree_root_scan, buf, 1);
- }
- }
- free_extent_buffer(buf);
- }
-next:
- path.slots[0]++;
- }
-no_node:
- btrfs_release_path(&path);
-
- if (tree_root_scan == info->tree_root &&
- info->log_root_tree) {
- tree_root_scan = info->log_root_tree;
- goto again;
- }