aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-11-12 12:09:14 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-11-12 12:09:14 +0100
commitcd0936be361ad2566200479d66fc1e5671182b73 (patch)
treeea80e1bd884cd37cfd38ef251802f16cf9d8d75d /util-linux
parentd3092c99ae90f2be2e1f990eab15921ea26652fd (diff)
downloadbusybox-w32-cd0936be361ad2566200479d66fc1e5671182b73.tar.gz
busybox-w32-cd0936be361ad2566200479d66fc1e5671182b73.tar.bz2
busybox-w32-cd0936be361ad2566200479d66fc1e5671182b73.zip
fstrim: use new-style config/kbuild/applet snippets; trim help text
function old new delta packed_usage 29546 29520 -26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/Config.src7
-rw-r--r--util-linux/Kbuild.src1
-rw-r--r--util-linux/fstrim.c34
3 files changed, 22 insertions, 20 deletions
diff --git a/util-linux/Config.src b/util-linux/Config.src
index ef7039720..5a8b0063b 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -246,13 +246,6 @@ config FSCK_MINIX
246 check for and attempt to repair any corruption that occurs to a minix 246 check for and attempt to repair any corruption that occurs to a minix
247 filesystem. 247 filesystem.
248 248
249config FSTRIM
250 bool "fstrim"
251 default y
252 select PLATFORM_LINUX
253 help
254 Discard unused blocks on a mounted filesystem.
255
256config MKFS_EXT2 249config MKFS_EXT2
257 bool "mkfs_ext2" 250 bool "mkfs_ext2"
258 default y 251 default y
diff --git a/util-linux/Kbuild.src b/util-linux/Kbuild.src
index 429cf1100..468fc6bc1 100644
--- a/util-linux/Kbuild.src
+++ b/util-linux/Kbuild.src
@@ -18,7 +18,6 @@ lib-$(CONFIG_FINDFS) += findfs.o
18lib-$(CONFIG_FLOCK) += flock.o 18lib-$(CONFIG_FLOCK) += flock.o
19lib-$(CONFIG_FREERAMDISK) += freeramdisk.o 19lib-$(CONFIG_FREERAMDISK) += freeramdisk.o
20lib-$(CONFIG_FSCK_MINIX) += fsck_minix.o 20lib-$(CONFIG_FSCK_MINIX) += fsck_minix.o
21lib-$(CONFIG_FSTRIM) += fstrim.o
22lib-$(CONFIG_GETOPT) += getopt.o 21lib-$(CONFIG_GETOPT) += getopt.o
23lib-$(CONFIG_HEXDUMP) += hexdump.o 22lib-$(CONFIG_HEXDUMP) += hexdump.o
24lib-$(CONFIG_HWCLOCK) += hwclock.o 23lib-$(CONFIG_HWCLOCK) += hwclock.o
diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c
index 4d90fa7a3..675a02184 100644
--- a/util-linux/fstrim.c
+++ b/util-linux/fstrim.c
@@ -8,21 +8,31 @@
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10 10
11//config:config FSTRIM
12//config: bool "fstrim"
13//config: default y
14//config: select PLATFORM_LINUX
15//config: help
16//config: Discard unused blocks on a mounted filesystem.
17
18//applet:IF_FSTRIM(APPLET(fstrim, BB_DIR_SBIN, BB_SUID_DROP))
19
20//kbuild:lib-$(CONFIG_FSTRIM) += fstrim.o
21
11//usage:#define fstrim_trivial_usage 22//usage:#define fstrim_trivial_usage
12//usage: "[Options] <mountpoint>" 23//usage: "[OPTIONS] MOUNTPOINT"
13//usage:#define fstrim_full_usage "\n\n" 24//usage:#define fstrim_full_usage "\n\n"
14//usage: "Options:"
15//usage: IF_LONG_OPTS( 25//usage: IF_LONG_OPTS(
16//usage: "\n -o,--offset=offset offset in bytes to discard from" 26//usage: " -o,--offset=OFFSET Offset in bytes to discard from"
17//usage: "\n -l,--length=length length of bytes to discard from the offset" 27//usage: "\n -l,--length=LEN Bytes to discard"
18//usage: "\n -m,--minimum=minimum minimum extent length to discard" 28//usage: "\n -m,--minimum=MIN Minimum extent length"
19//usage: "\n -v,--verbose print number of discarded bytes" 29//usage: "\n -v,--verbose Print number of discarded bytes"
20//usage: ) 30//usage: )
21//usage: IF_NOT_LONG_OPTS( 31//usage: IF_NOT_LONG_OPTS(
22//usage: "\n -o offset offset in bytes to discard from" 32//usage: " -o OFFSET Offset in bytes to discard from"
23//usage: "\n -l length length of bytes to discard from the offset" 33//usage: "\n -l LEN Bytes to discard"
24//usage: "\n -m minimum minimum extent length to discard" 34//usage: "\n -m MIN Minimum extent length"
25//usage: "\n -v, print number of discarded bytes" 35//usage: "\n -v, Print number of discarded bytes"
26//usage: ) 36//usage: )
27 37
28#include "libbb.h" 38#include "libbb.h"
@@ -94,7 +104,7 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv)
94 if (opts & OPT_m) 104 if (opts & OPT_m)
95 range.minlen = xatoull_sfx(arg_m, fstrim_sfx); 105 range.minlen = xatoull_sfx(arg_m, fstrim_sfx);
96 106
97 mp = *(argv += optind); 107 mp = argv[optind];
98 if (find_block_device(mp)) { 108 if (find_block_device(mp)) {
99 fd = xopen_nonblocking(mp); 109 fd = xopen_nonblocking(mp);
100 xioctl(fd, FITRIM, &range); 110 xioctl(fd, FITRIM, &range);
@@ -102,7 +112,7 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv)
102 close(fd); 112 close(fd);
103 113
104 if (opts & OPT_v) 114 if (opts & OPT_v)
105 printf("%s: %llu bytes were trimmed\n", mp, range.len); 115 printf("%s: %llu bytes trimmed\n", mp, (unsigned long long)range.len);
106 return EXIT_SUCCESS; 116 return EXIT_SUCCESS;
107 } 117 }
108 return EXIT_FAILURE; 118 return EXIT_FAILURE;