summaryrefslogtreecommitdiff
path: root/cmds-fi-disk_usage.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-04-24 15:21:16 +0200
committerDavid Sterba <dsterba@suse.cz>2014-12-04 16:48:10 +0100
commit6e4d756dee1cc8191cc8da43b6fdd22838fc88fb (patch)
tree8a4a3177b8b77f790d1f071b5a6fdbe022cba25b /cmds-fi-disk_usage.c
parentf4e73c060d5de4f809b8cfaeee7491c35ecd3c4b (diff)
btrfs-progs: check if we can't get info from ioctls due to permissions
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@suse.cz>
Diffstat (limited to 'cmds-fi-disk_usage.c')
-rw-r--r--cmds-fi-disk_usage.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index f432fa57..8bc4f58f 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -172,6 +172,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;