btrfs-progs: use existing rootid resolving helper in btrfs_list_get_path_rootid
authorDavid Sterba <dsterba@suse.com>
Mon, 31 Oct 2016 09:38:31 +0000 (10:38 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Nov 2016 12:47:28 +0000 (13:47 +0100)
The utils helper is not verbose in case of an error, for now the helper
used for subvolume listing will print the error message but not
duplicate the ioctl anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-list.c
cmds-receive.c
cmds-subvolume.c
utils.c

index b5d4458..831b13d 100644 (file)
@@ -1888,19 +1888,12 @@ int btrfs_list_parse_filter_string(char *opt_arg,
 
 int btrfs_list_get_path_rootid(int fd, u64 *treeid)
 {
-       int  ret;
-       struct btrfs_ioctl_ino_lookup_args args;
-
-       memset(&args, 0, sizeof(args));
-       args.objectid = BTRFS_FIRST_FREE_OBJECTID;
+       int ret;
 
-       ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
-       if (ret < 0) {
-               fprintf(stderr,
-                       "ERROR: can't perform the search - %s\n",
+       ret = lookup_path_rootid(fd, treeid);
+       if (ret < 0)
+               error("cannot resolve rootid for path: %s",
                        strerror(errno));
-               return ret;
-       }
-       *treeid = args.treeid;
-       return 0;
+
+       return ret;
 }
index d0525bf..62a7985 100644 (file)
@@ -1106,11 +1106,8 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt,
         * subvols we want to receive in.
         */
        ret = btrfs_list_get_path_rootid(r->mnt_fd, &subvol_id);
-       if (ret) {
-               error("cannot resolve our subvolid: %d",
-                       ret);
+       if (ret)
                goto out;
-       }
 
        root_subvol_path[0] = 0;
        ret = btrfs_subvolid_resolve(r->mnt_fd, root_subvol_path,
index bcfe5ed..3b5d6ea 100644 (file)
@@ -548,10 +548,8 @@ static int cmd_subvol_list(int argc, char **argv)
        }
 
        ret = btrfs_list_get_path_rootid(fd, &top_id);
-       if (ret) {
-               error("can't get rootid for '%s'", subvol);
+       if (ret)
                goto out;
-       }
 
        if (is_list_all)
                btrfs_list_setup_filter(&filter_set,
diff --git a/utils.c b/utils.c
index 3e1eb45..e10d199 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -4161,10 +4161,8 @@ int get_subvol_info(const char *fullpath, struct root_info *get_ri)
                goto out;
 
        ret = btrfs_list_get_path_rootid(fd, &sv_id);
-       if (ret) {
-               error("can't get rootid for '%s'", fullpath);
+       if (ret)
                goto out;
-       }
 
        mntfd = btrfs_open_dir(mnt, &dirstream2, 1);
        if (mntfd < 0)