wok-6.x view busybox/stuff/busybox-1.23-shutdown.u @ rev 18965

podofo: set FREETYPE_INCLUDE_DIR
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 10 19:10:25 2016 +0100 (2016-03-10)
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);