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