wok view busybox/stuff/busybox-1.23-shutdown.u @ rev 18635
mediainfo: add build depends
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Nov 27 10:38:59 2015 +0200 (2015-11-27) |
parents | |
children |
line source
1 --- busybox-1.23/init/halt.c
2 +++ busybox-1.23/init/halt.c
3 @@ -10,6 +10,7 @@
4 //applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP))
5 //applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff))
6 //applet:IF_HALT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot))
7 +//applet:IF_HALT(APPLET_ODDNAME(shutdown, halt, BB_DIR_SBIN, BB_SUID_DROP, shutdown))
9 //kbuild:lib-$(CONFIG_HALT) += halt.o
11 @@ -65,6 +66,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 @@ -98,6 +108,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 @@ -109,9 +120,19 @@
36 int which, flags, rc;
38 /* Figure out which applet we're running */
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 opt_complementary = "d+"; /* -d N */
55 /* We support -w even if !ENABLE_FEATURE_WTMP,
56 @@ -119,6 +140,7 @@
57 * -i (shut down network interfaces) is ignored.
58 */
59 flags = getopt32(argv, "d:nfwi", &delay);
60 + }
62 sleep(delay);