mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-17 10:16:53 +00:00
btrfs-progs: dump-tree: add option to print children nodes of a given block
When debuging with "btrfs inspect dump-tree", it's not that handy if we want to iterate all child tree blocks starting from a specified block. -b can only print a single block, while without -b "btrfs inspect dump-tree" will need extra tree roots fulfilled to continue, which is not possible for a damaged filesystem. Add a new option --follow to iterate a sub-tree starting from block specified by --block. Signed-off-by: Qu Wenruo <wqu@suse.com> [ remove the short option for now ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f37ae8d275
commit
992aa55839
@ -87,6 +87,8 @@ the respective tree root block offset
|
|||||||
print only the uuid tree information, empty output if the tree does not exist
|
print only the uuid tree information, empty output if the tree does not exist
|
||||||
-b <block_num>::::
|
-b <block_num>::::
|
||||||
print info of the specified block only
|
print info of the specified block only
|
||||||
|
--follow::::
|
||||||
|
use with '-b', print all children tree blocks of '<block_num>'
|
||||||
-t <tree_id>::::
|
-t <tree_id>::::
|
||||||
print only the tree with the specified ID, where the ID can be numerical or
|
print only the tree with the specified ID, where the ID can be numerical or
|
||||||
common name in a flexible human readable form
|
common name in a flexible human readable form
|
||||||
|
@ -198,6 +198,7 @@ const char * const cmd_inspect_dump_tree_usage[] = {
|
|||||||
"-u|--uuid print only the uuid tree",
|
"-u|--uuid print only the uuid tree",
|
||||||
"-b|--block <block_num> print info from the specified block only",
|
"-b|--block <block_num> print info from the specified block only",
|
||||||
"-t|--tree <tree_id> print only tree with the given id (string or number)",
|
"-t|--tree <tree_id> print only tree with the given id (string or number)",
|
||||||
|
"--follow use with -b, to show all children tree blocks of <block_num>",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -223,9 +224,11 @@ int cmd_inspect_dump_tree(int argc, char **argv)
|
|||||||
u64 block_only = 0;
|
u64 block_only = 0;
|
||||||
struct btrfs_root *tree_root_scan;
|
struct btrfs_root *tree_root_scan;
|
||||||
u64 tree_id = 0;
|
u64 tree_id = 0;
|
||||||
|
bool follow = false;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
|
enum { GETOPT_VAL_FOLLOW = 256 };
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "extents", no_argument, NULL, 'e'},
|
{ "extents", no_argument, NULL, 'e'},
|
||||||
{ "device", no_argument, NULL, 'd'},
|
{ "device", no_argument, NULL, 'd'},
|
||||||
@ -234,6 +237,7 @@ int cmd_inspect_dump_tree(int argc, char **argv)
|
|||||||
{ "uuid", no_argument, NULL, 'u'},
|
{ "uuid", no_argument, NULL, 'u'},
|
||||||
{ "block", required_argument, NULL, 'b'},
|
{ "block", required_argument, NULL, 'b'},
|
||||||
{ "tree", required_argument, NULL, 't'},
|
{ "tree", required_argument, NULL, 't'},
|
||||||
|
{ "follow", no_argument, NULL, GETOPT_VAL_FOLLOW },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -286,6 +290,9 @@ int cmd_inspect_dump_tree(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GETOPT_VAL_FOLLOW:
|
||||||
|
follow = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(cmd_inspect_dump_tree_usage);
|
usage(cmd_inspect_dump_tree_usage);
|
||||||
}
|
}
|
||||||
@ -324,7 +331,7 @@ int cmd_inspect_dump_tree(int argc, char **argv)
|
|||||||
(unsigned long long)block_only);
|
(unsigned long long)block_only);
|
||||||
goto close_root;
|
goto close_root;
|
||||||
}
|
}
|
||||||
btrfs_print_tree(root, leaf, 0);
|
btrfs_print_tree(root, leaf, follow);
|
||||||
free_extent_buffer(leaf);
|
free_extent_buffer(leaf);
|
||||||
goto close_root;
|
goto close_root;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user