# HG changeset patch # User Pascal Bellard # Date 1442851017 -7200 # Node ID ca1faa27f5262da7c1cdb97b193f16d8a574f948 # Parent 68bd2134ab5430d1367bd3465791774e786a8c1d busybox: add shutdown diff -r 68bd2134ab54 -r ca1faa27f526 busybox/receipt --- a/busybox/receipt Mon Sep 21 13:17:35 2015 +0000 +++ b/busybox/receipt Mon Sep 21 17:56:57 2015 +0200 @@ -46,6 +46,7 @@ cpio.u ftpd.u dpkgxz.u +shutdown.u EOT cp $stuff/$PACKAGE-${VERSION%.*}.config .config } diff -r 68bd2134ab54 -r ca1faa27f526 busybox/stuff/busybox-1.23-shutdown.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.23-shutdown.u Mon Sep 21 17:56:57 2015 +0200 @@ -0,0 +1,63 @@ +--- busybox-1.23/init/halt.c ++++ busybox-1.23/init/halt.c +@@ -10,6 +10,7 @@ + //applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP)) + //applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff)) + //applet:IF_HALT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot)) ++//applet:IF_HALT(APPLET_ODDNAME(shutdown, halt, BB_DIR_SBIN, BB_SUID_DROP, shutdown)) + + //kbuild:lib-$(CONFIG_HALT) += halt.o + +@@ -65,6 +66,15 @@ + //usage: "\n -d SEC Delay interval" + //usage: "\n -n Do not sync" + //usage: "\n -f Force (don't go through init)" ++//usage: ++//usage:#define shutdown_trivial_usage ++//usage: "[-rhHP]" ++//usage:#define shutdown_full_usage "\n\n" ++//usage: "Bring the system down\n" ++//usage: "\n -r Do reboot" ++//usage: "\n -h Do poweroff" ++//usage: "\n -H Do halt" ++//usage: "\n -P Do poweroff" + + #include "libbb.h" + #include "reboot.h" +@@ -98,6 +108,7 @@ + int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int halt_main(int argc UNUSED_PARAM, char **argv) + { ++ enum { HALT=0, POWEROFF=1, REBOOT=2, SHUTDOWN=3 }; + static const int magic[] = { + RB_HALT_SYSTEM, + RB_POWER_OFF, +@@ -109,9 +120,19 @@ + int which, flags, rc; + + /* Figure out which applet we're running */ +- for (which = 0; "hpr"[which] != applet_name[0]; which++) ++ for (which = 0; "hprs"[which] != applet_name[0]; which++) + continue; + ++ if (which == SHUTDOWN) { ++ which = REBOOT; ++ switch (getopt32(argv, "rhPH")) { ++ case 2: ++ case 4: which = POWEROFF; break; ++ case 8: which = HALT; ++ } ++ flags = 0; ++ } ++ else { + /* Parse and handle arguments */ + opt_complementary = "d+"; /* -d N */ + /* We support -w even if !ENABLE_FEATURE_WTMP, +@@ -119,6 +140,7 @@ + * -i (shut down network interfaces) is ignored. + */ + flags = getopt32(argv, "d:nfwi", &delay); ++ } + + sleep(delay); +