btrfs-progs: inspect subvolid-resolve: fix argument parsing
authorSatoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Fri, 18 Mar 2016 01:31:32 +0000 (10:31 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 18 Mar 2016 13:14:03 +0000 (14:14 +0100)
"inspect-internal subvolid-resolve" doesn't work from the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

It's because 1st argument, subvolid, is also used for the pathname of
filesystem. 2nd argument should be used for this purpose instead.

* actual result

   ==================================================
   # ./btrfs inspect-internal subvolid-resolve 260 /btrfs
   ERROR: cannot access '260': No such file or directory
   ==================================================

* expected result

   ==================================================
   # btrfs inspect-internal subvolid-resolve 260 /btrfs
   snap
   ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-inspect.c

index 04e1ae86e7e103b2796acc7b8513139807dc53f5..6045985fc869ef3d4dbb79d3f05d883a9a317e93 100644 (file)
@@ -273,7 +273,7 @@ static int cmd_inspect_subvolid_resolve(int argc, char **argv)
        if (check_argc_exact(argc - optind, 2))
                usage(cmd_inspect_subvolid_resolve_usage);
 
-       fd = btrfs_open_dir(argv[optind], &dirstream, 1);
+       fd = btrfs_open_dir(argv[optind + 1], &dirstream, 1);
        if (fd < 0) {
                ret = -ENOENT;
                goto out;