btrfs-progs/common
David Sterba 4980de3a5f btrfs-progs: read partition size from sysfs as fallback
Reading partition size using an ioctl requires the device open, but that
does not work for unprivileged users. This leads to 0 size in device
info structures filled by device_get_partition_size.

As a consequence, this also misreports such devices as missing in 'fi
us' overview:

 $ btrfs fi us /
 WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root
 Overall:
     Device size:		 411.35GiB
     Device allocated:		  53.01GiB
     Device unallocated:	 358.34GiB
     Device missing:		 411.35GiB
     Used:			  31.99GiB
     Free (estimated):		 379.16GiB	(min: 379.16GiB)
     Free (statfs, df):		 379.35GiB
     Data ratio:		      1.00
     Metadata ratio:		      1.00
     Global reserve:		 194.77MiB	(used: 0.00B)
     Multiple profiles:		        no

There should be 0 for 'Device missing'.

Add a fallback to read the device size from sysfs in case the ioctl is
not available.

Issue: #395
Signed-off-by: David Sterba <dsterba@suse.com>
2021-09-10 13:09:05 +02:00
..
box.h btrfs-progs: build most common tools into one binary (busybox style) 2019-07-04 15:30:40 +02:00
defs.h btrfs-progs: move common-defs to common/ 2020-03-31 18:37:35 +02:00
device-scan.c btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock 2021-05-12 16:00:14 +02:00
device-scan.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
device-utils.c btrfs-progs: read partition size from sysfs as fallback 2021-09-10 13:09:05 +02:00
device-utils.h btrfs-progs: add helper to read zone size from sysfs 2021-07-02 17:27:53 +02:00
extent-cache.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
extent-cache.h btrfs-progs: move extent-cache.c to common/ 2020-08-31 17:01:04 +02:00
format-output.c btrfs-progs: split unit related helpers from utils.c 2021-05-06 16:41:47 +02:00
format-output.h btrfs-progs: lots of typo fixes (codespell) 2020-03-31 18:37:38 +02:00
fsfeatures.c btrfs-progs: move btrfs_tree_search2_ioctl_supported to fsfeatures.c 2021-09-07 16:20:17 +02:00
fsfeatures.h btrfs-progs: move btrfs_tree_search2_ioctl_supported to fsfeatures.c 2021-09-07 16:20:17 +02:00
help.c btrfs-progs: split global help HELPINFO_INSERT_GLOBALS 2020-06-12 19:30:36 +02:00
help.h btrfs-progs: add global verbose and quiet options and helper functions 2020-06-12 19:30:43 +02:00
internal.h
messages.c btrfs-progs: add global verbose and quiet options and helper functions 2020-06-12 19:30:43 +02:00
messages.h btrfs-progs: add separate verbosity level for on-by-default messages 2020-06-12 19:32:29 +02:00
open-utils.c btrfs-progs: split open/close helpers from utils.c 2021-05-06 16:41:47 +02:00
open-utils.h btrfs-progs: split open/close helpers from utils.c 2021-05-06 16:41:47 +02:00
parse-utils.c btrfs-progs: move parse_qgroupid to parse utils 2021-09-07 14:20:42 +02:00
parse-utils.h btrfs-progs: move parse_qgroupid to parse utils 2021-09-07 14:20:42 +02:00
path-utils.c btrfs-progs: receive: fix btrfs_mount_root substring bug 2021-02-19 16:29:40 +01:00
path-utils.h btrfs-progs: remove unnecessary linux/*.h includes 2021-05-06 16:41:47 +02:00
rbtree-utils.c btrfs-progs: move rbtree-utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
rbtree-utils.h btrfs-progs: move rbtree-utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
repair.c btrfs-progs: move repair.[ch] to common/ 2021-05-06 16:41:47 +02:00
repair.h btrfs-progs: move repair.[ch] to common/ 2021-05-06 16:41:47 +02:00
send-stream.c btrfs-progs: move send.h to kernel-shared/ 2021-09-07 19:26:46 +02:00
send-stream.h btrfs-progs: move send-stream.c to common/ 2020-08-31 17:01:04 +02:00
send-utils.c btrfs-progs: open code btrfs_list_get_path_rootid 2021-09-08 16:35:47 +02:00
send-utils.h btrfs-progs: move ctree.c to kernel-shared/ 2020-08-31 17:01:05 +02:00
string-table.c btrfs-progs: move string-table.[ch] to common/ 2019-07-03 20:49:03 +02:00
string-table.h btrfs-progs: move string-table.[ch] to common/ 2019-07-03 20:49:03 +02:00
task-utils.c btrfs-progs: move task-utils.[ch] to common/ 2019-07-03 20:49:03 +02:00
task-utils.h btrfs-progs: move task-utils.[ch] to common/ 2019-07-03 20:49:03 +02:00
units.c btrfs-progs: split unit related helpers from utils.c 2021-05-06 16:41:47 +02:00
units.h btrfs-progs: split unit related helpers from utils.c 2021-05-06 16:41:47 +02:00
utils-lib.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
utils.c btrfs-progs: rename and move group_profile_max_safe_loss 2021-09-07 16:38:56 +02:00
utils.h btrfs-progs: rename and move group_profile_max_safe_loss 2021-09-07 16:38:56 +02:00