Make halt/poweroff/reboot independently selectable
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 14 Nov 2016 03:55:04 +0000 (04:55 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 14 Nov 2016 03:55:04 +0000 (04:55 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
init/halt.c

index 29e60657b8056f9b86b968f3a2a053bfe348cd04..b7fb108692a52dad8d34183ad6bffaddf69a21c3 100644 (file)
@@ -7,22 +7,28 @@
  * Licensed under GPLv2, see file LICENSE in this source tree.
  */
 
-//applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP))
-//applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff))
-//applet:IF_HALT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot))
-
-//kbuild:lib-$(CONFIG_HALT) += halt.o
-
 //config:config HALT
-//config:      bool "poweroff, halt, and reboot"
+//config:      bool "halt"
+//config:      default y
+//config:      help
+//config:        Stop all processes and halt the system.
+//config:
+//config:config POWEROFF
+//config:      bool "poweroff"
 //config:      default y
 //config:      help
-//config:        Stop all processes and either halt, reboot, or power off the system.
+//config:        Stop all processes and power off the system.
+//config:
+//config:config REBOOT
+//config:      bool "reboot"
+//config:      default y
+//config:      help
+//config:        Stop all processes and reboot the system.
 //config:
 //config:config FEATURE_CALL_TELINIT
 //config:      bool "Call telinit on shutdown and reboot"
 //config:      default y
-//config:      depends on HALT && !INIT
+//config:      depends on (HALT || POWEROFF || REBOOT) && !INIT
 //config:      help
 //config:        Call an external program (normally telinit) to facilitate
 //config:        a switch to a proper runlevel.
 //config:        to facilitate proper shutdown, this path is to be used when
 //config:        locating telinit executable.
 
+//applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP))
+//applet:IF_POWEROFF(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff))
+//applet:IF_REBOOT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot))
+
+//kbuild:lib-$(CONFIG_HALT) += halt.o
+//kbuild:lib-$(CONFIG_POWEROFF) += halt.o
+//kbuild:lib-$(CONFIG_REBOOT) += halt.o
+
 //usage:#define halt_trivial_usage
 //usage:       "[-d DELAY] [-n] [-f]" IF_FEATURE_WTMP(" [-w]")
 //usage:#define halt_full_usage "\n\n"
@@ -109,6 +123,15 @@ int halt_main(int argc UNUSED_PARAM, char **argv)
        int which, flags, rc;
 
        /* Figure out which applet we're running */
+       if (ENABLE_HALT && !ENABLE_POWEROFF && !ENABLE_REBOOT)
+               which = 0;
+       else
+       if (!ENABLE_HALT && ENABLE_POWEROFF && !ENABLE_REBOOT)
+               which = 1;
+       else
+       if (!ENABLE_HALT && !ENABLE_POWEROFF && ENABLE_REBOOT)
+               which = 2;
+       else
        for (which = 0; "hpr"[which] != applet_name[0]; which++)
                continue;