From: Denys Vlasenko Date: Thu, 29 Mar 2018 14:00:30 +0000 (+0200) Subject: fstrim: do not check that specified file is on a block device X-Git-Tag: 1_29_0~182 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3be4b9b0dee790bc19314411f109d6dcb14f97dc;p=oweals%2Fbusybox.git fstrim: do not check that specified file is on a block device Kernel will surely inform us in FITRIM does not make sense on a given file. function old new delta fstrim_main 241 221 -20 Signed-off-by: Denys Vlasenko --- diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c index 205d1e42b..558a94a9e 100644 --- a/util-linux/fstrim.c +++ b/util-linux/fstrim.c @@ -70,7 +70,9 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv) ; #endif - opts = getopt32long(argv, "^" "o:l:m:v" "\0" "=1", fstrim_longopts, + opts = getopt32long(argv, "^" + "o:l:m:v" + "\0" "=1", fstrim_longopts, &arg_o, &arg_l, &arg_m ); @@ -85,15 +87,21 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv) range.minlen = xatoull_sfx(arg_m, kmg_i_suffixes); mp = argv[optind]; - if (find_block_device(mp)) { +//Wwhy bother checking that it's a blockdev? +// if (find_block_device(mp)) { fd = xopen_nonblocking(mp); + + /* On ENOTTY error, util-linux 2.31 says: + * "fstrim: FILE: the discard operation is not supported" + */ xioctl(fd, FITRIM, &range); + if (ENABLE_FEATURE_CLEAN_UP) close(fd); if (opts & OPT_v) printf("%s: %llu bytes trimmed\n", mp, (unsigned long long)range.len); return EXIT_SUCCESS; - } +// } return EXIT_FAILURE; }