1303 files changed, 32187 insertions, 57138 deletions
diff --git a/init/halt.c b/init/halt.c index 7f1bebb..8073103 100644 --- a/init/halt.c +++ b/init/halt.c @@ -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. @@ -39,6 +45,14 @@ //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" @@ -78,7 +92,7 @@ static void write_wtmp(void) { - struct utmp utmp; + struct utmpx utmp; struct utsname uts; /* "man utmp" says wtmp file should *not* be created automagically */ /*if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) { @@ -92,7 +106,7 @@ static void write_wtmp(void) utmp.ut_line[0] = '~'; utmp.ut_line[1] = '~'; /* = strcpy(utmp.ut_line, "~~"); */ uname(&uts); safe_strncpy(utmp.ut_host, uts.release, sizeof(utmp.ut_host)); - updwtmp(bb_path_wtmp_file, &utmp); + updwtmpx(bb_path_wtmp_file, &utmp); } #else #define write_wtmp() ((void)0) @@ -113,16 +127,24 @@ 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; /* Parse and handle arguments */ - opt_complementary = "d+"; /* -d N */ /* We support -w even if !ENABLE_FEATURE_WTMP, * in order to not break scripts. * -i (shut down network interfaces) is ignored. */ - flags = getopt32(argv, "d:nfwi", &delay); + flags = getopt32(argv, "d:+nfwi", &delay); sleep(delay); @@ -164,7 +186,7 @@ int halt_main(int argc UNUSED_PARAM, char **argv) if (!(flags & 4)) { /* no -f */ //TODO: I tend to think that signalling linuxrc is wrong // pity original author didn't comment on it... - if (ENABLE_FEATURE_INITRD) { + if (ENABLE_LINUXRC) { /* talk to linuxrc */ /* bbox init/linuxrc assumed */ pid_t *pidlist = find_pid_by_name("linuxrc"); |