btrfs-progs: find-root, add option to search through all the metadata extents

Add option '-a' for btrfs-find-root to iterate all the metadata extents
even the root is already found.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
Qu Wenruo 2015-01-16 19:32:54 +08:00 committed by David Sterba
parent e08b2a5845
commit d91d68294c
2 changed files with 19 additions and 14 deletions

View File

@ -16,6 +16,8 @@ root tree's objectid, generation, level.
OPTIONS OPTIONS
------- -------
-a::
Search through all the metadata extents, even the root is already found.
-g <generation>:: -g <generation>::
Filter root tree by it's original transaction id, tree root's generation in default. Filter root tree by it's original transaction id, tree root's generation in default.
-o <objectid>:: -o <objectid>::

View File

@ -36,7 +36,7 @@
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "Usage: find-roots [-o search_objectid] " fprintf(stderr, "Usage: find-roots [-a] [-o search_objectid] "
"[ -g search_generation ] [ -l search_level ] <device>\n"); "[ -g search_generation ] [ -l search_level ] <device>\n");
} }
@ -149,20 +149,23 @@ int main(int argc, char **argv)
filter.objectid = BTRFS_ROOT_TREE_OBJECTID; filter.objectid = BTRFS_ROOT_TREE_OBJECTID;
filter.match_gen = (u64)-1; filter.match_gen = (u64)-1;
filter.match_level = (u8)-1; filter.match_level = (u8)-1;
while ((opt = getopt(argc, argv, "l:o:g:")) != -1) { while ((opt = getopt(argc, argv, "al:o:g:")) != -1) {
switch(opt) { switch(opt) {
case 'o': case 'a':
filter.objectid = arg_strtou64(optarg); filter.search_all = 1;
break; break;
case 'g': case 'o':
filter.generation = arg_strtou64(optarg); filter.objectid = arg_strtou64(optarg);
break; break;
case 'l': case 'g':
filter.level = arg_strtou64(optarg); filter.generation = arg_strtou64(optarg);
break; break;
default: case 'l':
usage(); filter.level = arg_strtou64(optarg);
exit(1); break;
default:
usage();
exit(1);
} }
} }