wok-next annotate busybox/stuff/busybox-1.26-shutdown.u @ rev 19592

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