diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-29 16:00:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-29 16:05:10 +0200 |
commit | 3be4b9b0dee790bc19314411f109d6dcb14f97dc (patch) | |
tree | 36d2ccf7d60606e4bba31a65783c9295927ff7d2 | |
parent | d1b845706df2aa819babe74cb0b9b15c13da6b16 (diff) | |
download | busybox-w32-3be4b9b0dee790bc19314411f109d6dcb14f97dc.tar.gz busybox-w32-3be4b9b0dee790bc19314411f109d6dcb14f97dc.tar.bz2 busybox-w32-3be4b9b0dee790bc19314411f109d6dcb14f97dc.zip |
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 <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/fstrim.c | 14 |
1 files changed, 11 insertions, 3 deletions
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) | |||
70 | ; | 70 | ; |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | opts = getopt32long(argv, "^" "o:l:m:v" "\0" "=1", fstrim_longopts, | 73 | opts = getopt32long(argv, "^" |
74 | "o:l:m:v" | ||
75 | "\0" "=1", fstrim_longopts, | ||
74 | &arg_o, &arg_l, &arg_m | 76 | &arg_o, &arg_l, &arg_m |
75 | ); | 77 | ); |
76 | 78 | ||
@@ -85,15 +87,21 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv) | |||
85 | range.minlen = xatoull_sfx(arg_m, kmg_i_suffixes); | 87 | range.minlen = xatoull_sfx(arg_m, kmg_i_suffixes); |
86 | 88 | ||
87 | mp = argv[optind]; | 89 | mp = argv[optind]; |
88 | if (find_block_device(mp)) { | 90 | //Wwhy bother checking that it's a blockdev? |
91 | // if (find_block_device(mp)) { | ||
89 | fd = xopen_nonblocking(mp); | 92 | fd = xopen_nonblocking(mp); |
93 | |||
94 | /* On ENOTTY error, util-linux 2.31 says: | ||
95 | * "fstrim: FILE: the discard operation is not supported" | ||
96 | */ | ||
90 | xioctl(fd, FITRIM, &range); | 97 | xioctl(fd, FITRIM, &range); |
98 | |||
91 | if (ENABLE_FEATURE_CLEAN_UP) | 99 | if (ENABLE_FEATURE_CLEAN_UP) |
92 | close(fd); | 100 | close(fd); |
93 | 101 | ||
94 | if (opts & OPT_v) | 102 | if (opts & OPT_v) |
95 | printf("%s: %llu bytes trimmed\n", mp, (unsigned long long)range.len); | 103 | printf("%s: %llu bytes trimmed\n", mp, (unsigned long long)range.len); |
96 | return EXIT_SUCCESS; | 104 | return EXIT_SUCCESS; |
97 | } | 105 | // } |
98 | return EXIT_FAILURE; | 106 | return EXIT_FAILURE; |
99 | } | 107 | } |