btrfs-progs: qgroups show: handle errors when resolving root id
authorDavid Sterba <dsterba@suse.com>
Mon, 31 Oct 2016 09:27:25 +0000 (10:27 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Nov 2016 12:47:28 +0000 (13:47 +0100)
If btrfs_get_path_rootid fails, prints an error message but continues.
Replace with a helper that returns an error.

Signed-off-by: David Sterba <dsterba@suse.com>
cmds-qgroup.c

index 9814941..7c5532c 100644 (file)
@@ -366,7 +366,13 @@ static int cmd_qgroup_show(int argc, char **argv)
        }
 
        if (filter_flag) {
-               qgroupid = btrfs_get_path_rootid(fd);
+               ret = lookup_ino_rootid(fd, &qgroupid);
+               if (ret < 0) {
+                       error("cannot resolve rootid for %s: %s",
+                                       path, strerror(-ret));
+                       close_file_or_dir(fd, dirstream);
+                       goto out;
+               }
                if (filter_flag & 0x1)
                        btrfs_qgroup_setup_filter(&filter_set,
                                        BTRFS_QGROUP_FILTER_ALL_PARENT,
@@ -382,6 +388,7 @@ static int cmd_qgroup_show(int argc, char **argv)
        if (ret < 0)
                error("can't list qgroups: %s", strerror(e));
 
+out:
        return !!ret;
 }