rev |
line source |
pascal@19991
|
1 --- busybox-1.27/init/halt.c
|
pascal@19991
|
2 +++ busybox-1.27/init/halt.c
|
pascal@19991
|
3 @@ -49,6 +49,7 @@
|
pascal@19991
|
4 // APPLET_ODDNAME:name main location suid_type help
|
pascal@19991
|
5 //applet:IF_POWEROFF(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff))
|
pascal@19991
|
6 //applet:IF_REBOOT( APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot))
|
pascal@19991
|
7 +//applet:IF_REBOOT( APPLET_ODDNAME(shutdown, halt, BB_DIR_SBIN, BB_SUID_DROP, shutdown))
|
pascal@19991
|
8
|
pascal@19991
|
9 //kbuild:lib-$(CONFIG_HALT) += halt.o
|
pascal@19991
|
10 //kbuild:lib-$(CONFIG_POWEROFF) += halt.o
|
pascal@19991
|
11 @@ -80,6 +81,15 @@
|
pascal@19991
|
12 //usage: "\n -d SEC Delay interval"
|
pascal@19991
|
13 //usage: "\n -n Do not sync"
|
pascal@19991
|
14 //usage: "\n -f Force (don't go through init)"
|
pascal@19991
|
15 +//usage:
|
pascal@19991
|
16 +//usage:#define shutdown_trivial_usage
|
pascal@19991
|
17 +//usage: "[-rhHP]"
|
pascal@19991
|
18 +//usage:#define shutdown_full_usage "\n\n"
|
pascal@19991
|
19 +//usage: "Bring the system down\n"
|
pascal@19991
|
20 +//usage: "\n -r Do reboot"
|
pascal@19991
|
21 +//usage: "\n -h Do poweroff"
|
pascal@19991
|
22 +//usage: "\n -H Do halt"
|
pascal@19991
|
23 +//usage: "\n -P Do poweroff"
|
pascal@19991
|
24
|
pascal@19991
|
25 #include "libbb.h"
|
pascal@19991
|
26 #include "reboot.h"
|
pascal@19991
|
27 @@ -113,6 +123,7 @@
|
pascal@19991
|
28 int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
pascal@19991
|
29 int halt_main(int argc UNUSED_PARAM, char **argv)
|
pascal@19991
|
30 {
|
pascal@19991
|
31 + enum { HALT=0, POWEROFF=1, REBOOT=2, SHUTDOWN=3 };
|
pascal@19991
|
32 static const int magic[] = {
|
pascal@19991
|
33 RB_HALT_SYSTEM,
|
pascal@19991
|
34 RB_POWER_OFF,
|
pascal@19991
|
35 @@ -133,15 +144,26 @@
|
pascal@19991
|
36 if (!ENABLE_HALT && !ENABLE_POWEROFF && ENABLE_REBOOT)
|
pascal@19991
|
37 which = 2;
|
pascal@19991
|
38 else
|
pascal@19991
|
39 - for (which = 0; "hpr"[which] != applet_name[0]; which++)
|
pascal@19991
|
40 + for (which = 0; "hprs"[which] != applet_name[0]; which++)
|
pascal@19991
|
41 continue;
|
pascal@19991
|
42
|
pascal@19991
|
43 + if (which == SHUTDOWN) {
|
pascal@19991
|
44 + which = REBOOT;
|
pascal@19991
|
45 + switch (getopt32(argv, "rhPH")) {
|
pascal@19991
|
46 + case 2:
|
pascal@19991
|
47 + case 4: which = POWEROFF; break;
|
pascal@19991
|
48 + case 8: which = HALT;
|
pascal@19991
|
49 + }
|
pascal@19991
|
50 + flags = 0;
|
pascal@19991
|
51 + }
|
pascal@19991
|
52 + else {
|
pascal@19991
|
53 /* Parse and handle arguments */
|
pascal@19991
|
54 /* We support -w even if !ENABLE_FEATURE_WTMP,
|
pascal@19991
|
55 * in order to not break scripts.
|
pascal@19991
|
56 * -i (shut down network interfaces) is ignored.
|
pascal@19991
|
57 */
|
pascal@19991
|
58 flags = getopt32(argv, "d:+nfwi", &delay);
|
pascal@19991
|
59 + }
|
pascal@19991
|
60
|
pascal@19991
|
61 sleep(delay);
|
pascal@19991
|
62
|