diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-11-14 17:30:50 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-11-14 17:30:50 +0100 |
commit | f417ffd88f194bbfd18605882ee242190c1bab34 (patch) | |
tree | 42d49dd65f7722e2c5322cd829acdf829c147655 /util-linux/swaponoff.c | |
parent | 1924e99ad3513990f317c4295c35d5861521555a (diff) | |
download | busybox-w32-f417ffd88f194bbfd18605882ee242190c1bab34.tar.gz busybox-w32-f417ffd88f194bbfd18605882ee242190c1bab34.tar.bz2 busybox-w32-f417ffd88f194bbfd18605882ee242190c1bab34.zip |
Make swapon and swapoff individually selectable.
For example, without swapoff, code shrinks by 277 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/swaponoff.c')
-rw-r--r-- | util-linux/swaponoff.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 6713852e5..0a2d23f50 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c | |||
@@ -7,6 +7,47 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //config:config SWAPON | ||
11 | //config: bool "swapon" | ||
12 | //config: default y | ||
13 | //config: select PLATFORM_LINUX | ||
14 | //config: help | ||
15 | //config: This option enables the 'swapon' utility. | ||
16 | //config: Once you have created some swap space using 'mkswap', you also need | ||
17 | //config: to enable your swap space with the 'swapon' utility. The 'swapoff' | ||
18 | //config: utility is used, typically at system shutdown, to disable any swap | ||
19 | //config: space. If you are not using any swap space, you can leave this | ||
20 | //config: option disabled. | ||
21 | //config: | ||
22 | //config:config FEATURE_SWAPON_DISCARD | ||
23 | //config: bool "Support discard option -d" | ||
24 | //config: default y | ||
25 | //config: depends on SWAPON | ||
26 | //config: help | ||
27 | //config: Enable support for discarding swap area blocks at swapon and/or as | ||
28 | //config: the kernel frees them. This option enables both the -d option on | ||
29 | //config: 'swapon' and the 'discard' option for swap entries in /etc/fstab. | ||
30 | //config: | ||
31 | //config:config FEATURE_SWAPON_PRI | ||
32 | //config: bool "Support priority option -p" | ||
33 | //config: default y | ||
34 | //config: depends on SWAPON | ||
35 | //config: help | ||
36 | //config: Enable support for setting swap device priority in swapon. | ||
37 | //config: | ||
38 | //config:config SWAPOFF | ||
39 | //config: bool "swapoff" | ||
40 | //config: default y | ||
41 | //config: select PLATFORM_LINUX | ||
42 | //config: help | ||
43 | //config: This option enables the 'swapoff' utility. | ||
44 | |||
45 | //applet:IF_SWAPON(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon)) | ||
46 | //applet:IF_SWAPOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff)) | ||
47 | |||
48 | //kbuild:lib-$(CONFIG_SWAPON) += swaponoff.o | ||
49 | //kbuild:lib-$(CONFIG_SWAPOFF) += swaponoff.o | ||
50 | |||
10 | //usage:#define swapon_trivial_usage | 51 | //usage:#define swapon_trivial_usage |
11 | //usage: "[-a] [-e]" IF_FEATURE_SWAPON_DISCARD(" [-d[POL]]") IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]" | 52 | //usage: "[-a] [-e]" IF_FEATURE_SWAPON_DISCARD(" [-d[POL]]") IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]" |
12 | //usage:#define swapon_full_usage "\n\n" | 53 | //usage:#define swapon_full_usage "\n\n" |
@@ -74,7 +115,15 @@ struct globals { | |||
74 | #endif | 115 | #endif |
75 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | 116 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
76 | 117 | ||
77 | #define do_swapoff (applet_name[5] == 'f') | 118 | #if ENABLE_SWAPOFF |
119 | # if ENABLE_SWAPON | ||
120 | # define do_swapoff (applet_name[5] == 'f') | ||
121 | # else | ||
122 | # define do_swapoff 1 | ||
123 | # endif | ||
124 | #else | ||
125 | # define do_swapoff 0 | ||
126 | #endif | ||
78 | 127 | ||
79 | /* Command line options */ | 128 | /* Command line options */ |
80 | enum { | 129 | enum { |