[PATCH 04/14] btrfs-progs: check if we can't get info from ioctls due to permissions

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

 



The TREE_SEARCH ioctl is root-only, FS_INFO will be available for
non-root users with an updated kernel, let the user know.

Signed-off-by: David Sterba <dsterba@xxxxxxx>
---
 cmds-fi-disk_usage.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 17202de1b6e8..64c85acafd51 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -171,6 +171,12 @@ int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count)
 	while (1) {
 		ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
 		e = errno;
+		if (ret == -EPERM) {
+			fprintf(stderr,
+				"ERROR: can't read detailed chunk info from ioctl(TREE_SEARCH), run as root\n");
+			return 0;
+		}
+
 		if (ret < 0) {
 			fprintf(stderr,
 				"ERROR: can't perform the search - %s\n",
@@ -461,6 +467,10 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 	*device_info_ptr = 0;
 
 	ret = ioctl(fd, BTRFS_IOC_FS_INFO, &fi_args);
+	if (ret == -EPERM) {
+		fprintf(stderr, "ERROR: can't get filesystem info from ioctl(FS_INFO), run as root\n");
+		return -1;
+	}
 	if (ret < 0) {
 		fprintf(stderr, "ERROR: cannot get filesystem info\n");
 		return -1;
-- 
1.9.0

--
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