btrfs-progs: fix wrong error msg for exec btrfsck as non-root
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Thu, 20 Feb 2014 02:49:05 +0000 (10:49 +0800)
committerChris Mason <clm@fb.com>
Fri, 21 Mar 2014 13:23:22 +0000 (06:23 -0700)
When exec btrfsck as non-root user on a disk, btrfsck will always
warn that "No such file or directory", despite that a directory
(e.g. /dev/vboxusb)actually exists. We just have no permission.
In this case, return the -errno set by the opendir call in
btrfs_scan_one_dir rather than blindly return -ENOENT.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
utils.c

diff --git a/utils.c b/utils.c
index 9a921f0..398678f 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -1111,7 +1111,7 @@ again:
        dirp = opendir(dirname);
        if (!dirp) {
                fprintf(stderr, "Unable to open %s for scanning\n", dirname);
-               ret = -ENOENT;
+               ret = -errno;
                goto fail;
        }
        while(1) {