aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-11-14 17:30:50 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-11-14 17:30:50 +0100
commitf417ffd88f194bbfd18605882ee242190c1bab34 (patch)
tree42d49dd65f7722e2c5322cd829acdf829c147655
parent1924e99ad3513990f317c4295c35d5861521555a (diff)
downloadbusybox-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>
-rw-r--r--include/applets.src.h2
-rw-r--r--util-linux/Config.src28
-rw-r--r--util-linux/Kbuild.src1
-rw-r--r--util-linux/swaponoff.c51
4 files changed, 50 insertions, 32 deletions
diff --git a/include/applets.src.h b/include/applets.src.h
index dbc45953c..f2c754b74 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -287,8 +287,6 @@ IF_STAT(APPLET(stat, BB_DIR_BIN, BB_SUID_DROP))
287IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP)) 287IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP))
288IF_STTY(APPLET(stty, BB_DIR_BIN, BB_SUID_DROP)) 288IF_STTY(APPLET(stty, BB_DIR_BIN, BB_SUID_DROP))
289IF_SUM(APPLET(sum, BB_DIR_USR_BIN, BB_SUID_DROP)) 289IF_SUM(APPLET(sum, BB_DIR_USR_BIN, BB_SUID_DROP))
290IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff))
291IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon))
292IF_SWITCH_ROOT(APPLET(switch_root, BB_DIR_SBIN, BB_SUID_DROP)) 290IF_SWITCH_ROOT(APPLET(switch_root, BB_DIR_SBIN, BB_SUID_DROP))
293IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP)) 291IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP))
294IF_TAC(APPLET_NOEXEC(tac, tac, BB_DIR_USR_BIN, BB_SUID_DROP, tac)) 292IF_TAC(APPLET_NOEXEC(tac, tac, BB_DIR_USR_BIN, BB_SUID_DROP, tac))
diff --git a/util-linux/Config.src b/util-linux/Config.src
index 922cabdb8..ee0d8a632 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -489,34 +489,6 @@ config SCRIPTREPLAY
489 This program replays a typescript, using timing information 489 This program replays a typescript, using timing information
490 given by script -t. 490 given by script -t.
491 491
492config SWAPONOFF
493 bool "swaponoff"
494 default y
495 select PLATFORM_LINUX
496 help
497 This option enables both the 'swapon' and the 'swapoff' utilities.
498 Once you have created some swap space using 'mkswap', you also need
499 to enable your swap space with the 'swapon' utility. The 'swapoff'
500 utility is used, typically at system shutdown, to disable any swap
501 space. If you are not using any swap space, you can leave this
502 option disabled.
503
504config FEATURE_SWAPON_DISCARD
505 bool "Support discard option -d"
506 default y
507 depends on SWAPONOFF
508 help
509 Enable support for discarding swap area blocks at swapon and/or as
510 the kernel frees them. This option enables both the -d option on
511 'swapon' and the 'discard' option for swap entries in /etc/fstab.
512
513config FEATURE_SWAPON_PRI
514 bool "Support priority option -p"
515 default y
516 depends on SWAPONOFF
517 help
518 Enable support for setting swap device priority in swapon.
519
520config SWITCH_ROOT 492config SWITCH_ROOT
521 bool "switch_root" 493 bool "switch_root"
522 default y 494 default y
diff --git a/util-linux/Kbuild.src b/util-linux/Kbuild.src
index 0b87c52ac..5ee5cf7ff 100644
--- a/util-linux/Kbuild.src
+++ b/util-linux/Kbuild.src
@@ -40,6 +40,5 @@ lib-$(CONFIG_READPROFILE) += readprofile.o
40lib-$(CONFIG_RTCWAKE) += rtcwake.o 40lib-$(CONFIG_RTCWAKE) += rtcwake.o
41lib-$(CONFIG_SCRIPT) += script.o 41lib-$(CONFIG_SCRIPT) += script.o
42lib-$(CONFIG_SCRIPTREPLAY) += scriptreplay.o 42lib-$(CONFIG_SCRIPTREPLAY) += scriptreplay.o
43lib-$(CONFIG_SWAPONOFF) += swaponoff.o
44lib-$(CONFIG_SWITCH_ROOT) += switch_root.o 43lib-$(CONFIG_SWITCH_ROOT) += switch_root.o
45lib-$(CONFIG_UMOUNT) += umount.o 44lib-$(CONFIG_UMOUNT) += umount.o
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 */
80enum { 129enum {