diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-18 19:15:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-18 19:15:29 +0200 |
commit | ab77e81a8527fa11a4f9392d97c2da037d6f4f98 (patch) | |
tree | d11608662dd14b776a4c4d30a6039d476231ca58 /klibc-utils/nuke.c | |
parent | 79747415d6db1f85389247522304c941b4287f9b (diff) | |
download | busybox-w32-ab77e81a8527fa11a4f9392d97c2da037d6f4f98.tar.gz busybox-w32-ab77e81a8527fa11a4f9392d97c2da037d6f4f98.tar.bz2 busybox-w32-ab77e81a8527fa11a4f9392d97c2da037d6f4f98.zip |
klibc-utils: new applets: resume, nuke, minips
minips is a pure alias to ps, just in case someone needs 100% klibc-utils compat.
nuke is a primitive version of "rm -rf" without options and error checks. ~30 bytes.
resume is a tool for initramfs which resumes from a given block device.
function old new delta
resume_main - 582 +582
packed_usage 31640 31712 +72
nuke_main - 28 +28
xstrtoull - 24 +24
applet_names 2646 2665 +19
applet_main 1532 1544 +12
applet_suid 96 97 +1
applet_install_loc 192 193 +1
applet_flags 96 97 +1
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 6/0 up/down: 740/0) Total: 740 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'klibc-utils/nuke.c')
-rw-r--r-- | klibc-utils/nuke.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/klibc-utils/nuke.c b/klibc-utils/nuke.c new file mode 100644 index 000000000..363e03cce --- /dev/null +++ b/klibc-utils/nuke.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017 Denys Vlasenko <vda.linux@googlemail.com> | ||
3 | * | ||
4 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
5 | */ | ||
6 | //config:config NUKE | ||
7 | //config: bool "nuke" | ||
8 | //config: default y | ||
9 | //config: help | ||
10 | //config: Alias to "rm -rf". | ||
11 | |||
12 | //applet:IF_NUKE(APPLET_NOEXEC(nuke, nuke, BB_DIR_BIN, BB_SUID_DROP, nuke)) | ||
13 | |||
14 | //kbuild:lib-$(CONFIG_NUKE) += nuke.o | ||
15 | |||
16 | //usage:#define nuke_trivial_usage | ||
17 | //usage: "DIR..." | ||
18 | //usage:#define nuke_full_usage "\n\n" | ||
19 | //usage: "Resursively remove DIRs" | ||
20 | |||
21 | #include "libbb.h" | ||
22 | |||
23 | /* This is a NOEXEC applet. Be very careful! */ | ||
24 | |||
25 | int nuke_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
26 | int nuke_main(int argc UNUSED_PARAM, char **argv) | ||
27 | { | ||
28 | // klibc-utils do not check opts, will try to delete "-dir" args | ||
29 | //opt = getopt32(argv, ""); | ||
30 | //argv += optind; | ||
31 | |||
32 | while (*++argv) { | ||
33 | #if 0 | ||
34 | // klibc-utils do not check this, will happily operate on ".." | ||
35 | const char *base = bb_get_last_path_component_strip(*argv); | ||
36 | if (DOT_OR_DOTDOT(base)) { | ||
37 | bb_error_msg("can't remove '.' or '..'"); | ||
38 | continue; | ||
39 | } | ||
40 | #endif | ||
41 | remove_file(*argv, FILEUTILS_FORCE | FILEUTILS_RECUR); | ||
42 | } | ||
43 | |||
44 | // klibc-utils do not indicate errors | ||
45 | return EXIT_SUCCESS; | ||
46 | } | ||