btrfs-progs/common
Wang Yugui 683f41bfb0 btrfs-progs: fix discard support check
[BUG]
mkfs.btrfs v5.15  outputs a message even if the disk is a HDD without
TRIM/DISCARD support:

  Performing full device TRIM /dev/sdc2 (326.03GiB) ...

[CAUSE]
mkfs.btrfs check TRIM/DISCARD support through the content of
queue/discard_granularity, but compare it against a wrong value.

When HDD without TRIM/DISCARD support, the content of
queue/discard_granularity is '0' '\n' '\0', rather than '0' '\0'.

[FIX]

- compare the value based on atoi() to provide more robustness
- delete unnecessary '\n' in pr_verbose()

Fixes: c50c448518 ("btrfs-progs: do sysfs detection of device discard capability")
Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-11-18 10:17:21 +01: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: remove temporary buffer for super block 2021-11-05 12:50:03 +01:00
device-scan.h btrfs-progs: clean up test_uuid_unique 2021-10-08 20:46:33 +02:00
device-utils.c btrfs-progs: fix discard support check 2021-11-18 10:17:21 +01:00
device-utils.h btrfs-progs: introduce btrfs_pread wrapper for pread 2021-10-20 18:59:23 +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: mkfs: enable space_cache=v2 (free-space-tree) by default 2021-10-08 20:47:03 +02:00
fsfeatures.h btrfs-progs: drop ZONED flag from BTRFS_CONVERT_ALLOWED_FEATURES 2021-10-08 20:47:04 +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 btrfs-progs: move internal.h to common/ 2019-07-03 20:49:03 +02:00
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: make "btrfs filesystem df" command show upper case profile 2021-11-05 12:50:03 +01: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: remove c++ protection from internal headers 2021-10-08 20:47: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: receive: add missing unused inode number reads from the stream 2021-10-29 17:29:57 +02:00
send-stream.h btrfs-progs: remove BTRFS_FLAT_INCLUDES from internal send headers 2021-10-08 20:46:34 +02:00
send-utils.c btrfs-progs: remove unused subvol_uuid_search_add 2021-10-08 20:47:04 +02:00
send-utils.h btrfs-progs: remove unused subvol_uuid_search_add 2021-10-08 20:47:04 +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.c btrfs-progs: remove temporary buffer for super block 2021-11-05 12:50:03 +01:00
utils.h btrfs-progs: don't include btrfs-list.h unless necessary 2021-10-08 20:47:03 +02:00