btrfsprogs/0021-btrfs-progs-check-if-we-can-t-get-info-from-ioctls-d.patch
David Sterba 3ee7e4de90 Accepting request 259501 from home:dsterba:branches:filesystems
- version 3.17
  - check: --init-csum-tree acutally does something useful, rebuilds the whole
    csum tree
  - /dev scanning for btrfs devices is gone
  - /proc/partitions scanning is gone, blkid is used exclusively
  - new subcommand subvolume sync
  - filesystem df: new options to set unit format
  - convert: allow to copy label from the origin, or specify a new one

(not all local patches are upstream, maybe next time)

OBS-URL: https://build.opensuse.org/request/show/259501
OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=176
2014-11-03 13:17:26 +00:00

46 lines
1.4 KiB
Diff

From 10fd49e8ced9a8fe34a409ab76c69488b9aef704 Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.cz>
Date: Thu, 24 Apr 2014 15:21:16 +0200
Subject: [PATCH 11/42] 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>
---
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 f432fa57fb91..8bc4f58fee0b 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;
--
2.1.1