btrfs-progs: qgroup show: refine error messages
authorDavid Sterba <dsterba@suse.com>
Fri, 20 Jan 2017 16:52:12 +0000 (17:52 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 25 Jan 2017 08:47:58 +0000 (09:47 +0100)
When qgroup show is called on a filesystem that does not have quotas
enabled, the error message is very unclear:

  ERROR: can't perform the search - No such file or directory
  ERROR: can't list qgroups: No such file or director

Remove the error from low level helper and let the command handler
decide what to print.

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

index 59a5926..d0f10dd 100644 (file)
@@ -382,9 +382,11 @@ static int cmd_qgroup_show(int argc, char **argv)
                                        qgroupid);
        }
        ret = btrfs_show_qgroups(fd, filter_set, comparer_set);
-       close_file_or_dir(fd, dirstream);
-       if (ret < 0)
+       if (ret == -ENOENT)
+               error("can't list qgroups: quotas not enabled");
+       else if (ret < 0)
                error("can't list qgroups: %s", strerror(-ret));
+       close_file_or_dir(fd, dirstream);
 
 out:
        return !!ret;
index 21526ce..fffdbb1 100644 (file)
--- a/qgroup.c
+++ b/qgroup.c
@@ -1064,11 +1064,9 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
 
        while (1) {
                ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
-               if (ret < 0) {
-                       error("cannot perform the search: %s",
-                                       strerror(errno));
+               if (ret < 0)
                        return -errno;
-               }
+
                /* the ioctl returns the number of item it found in nr_items */
                if (sk->nr_items == 0)
                        break;