diff mbox

[3/4] btrfs-progs: fix wrong error msg for exec btrfsck as non-root

Message ID 1392864546-545-3-git-send-email-guihc.fnst@cn.fujitsu.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Gui Hecheng Feb. 20, 2014, 2:49 a.m. UTC
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>
---
 utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/utils.c b/utils.c
index 1878abc..12ed2f4 100644
--- a/utils.c
+++ b/utils.c
@@ -1114,7 +1114,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) {