Re: [PATCH] Btrfs-progs: Exit if not running as root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/25/13 9:04 AM, Gene Czarcinski wrote:
> OK, I think I have gotten the message that this is a bad idea as
> implemented and that it should be dropped as such.  I believe that
> there are some things ("btrfs fi show" comes to mind) which will need
> root and I am going to explore doing something for that case.  And it
> also might be reasonable for some situations to issue the message
> about root if something errors-out.

So, in that particular case, I think the right fix is to make the code
in that spot be more informative; there are probably a whole lot of
places that could use fixes like this, though, not just this one.
Still, it would be helpful to the user, I think.

i.e. show:

[testuser@host btrfs-progs]$ whoami
testuser
[testuser@host btrfs-progs]$ ./btrfs fi show
failed to open /dev/sda: Permission denied
failed to open /dev/sda1: Permission denied
...


[PATCH] print more informative error when we fail to open a device

If open() fails, we should let the user know why it failed.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/utils.c b/utils.c
index 595850b..a5673f7 100644
--- a/utils.c
+++ b/utils.c
@@ -1237,7 +1237,8 @@ scan_again:
 
 		fd = open(fullpath, O_RDONLY);
 		if (fd < 0) {
-			fprintf(stderr, "failed to read %s\n", fullpath);
+			fprintf(stderr, "failed to open %s: %s\n",
+				fullpath, strerror(errno));
 			continue;
 		}
 		ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux