wok-6.x diff busybox/stuff/busybox-1.31-shutdown.u @ rev 21954

Up putty (0.73)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Oct 09 18:12:57 2019 +0200 (2019-10-09)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.31-shutdown.u	Wed Oct 09 18:12:57 2019 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +--- busybox-1.31/init/halt.c
     1.5 ++++ busybox-1.31/init/halt.c
     1.6 +@@ -59,6 +59,7 @@
     1.7 + //                   APPLET_ODDNAME:name      main  location     suid_type     help
     1.8 + //applet:IF_POWEROFF(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff))
     1.9 + //applet:IF_REBOOT(  APPLET_ODDNAME(reboot,   halt, BB_DIR_SBIN, BB_SUID_DROP, reboot))
    1.10 ++//applet:IF_REBOOT(  APPLET_ODDNAME(shutdown, halt, BB_DIR_SBIN, BB_SUID_DROP, shutdown))
    1.11 + 
    1.12 + //kbuild:lib-$(CONFIG_HALT) += halt.o
    1.13 + //kbuild:lib-$(CONFIG_POWEROFF) += halt.o
    1.14 +@@ -90,6 +91,15 @@
    1.15 + //usage:     "\n	-d SEC	Delay interval"
    1.16 + //usage:     "\n	-n	Do not sync"
    1.17 + //usage:     "\n	-f	Force (don't go through init)"
    1.18 ++//usage:
    1.19 ++//usage:#define shutdown_trivial_usage
    1.20 ++//usage:       "[-rhHP]"
    1.21 ++//usage:#define shutdown_full_usage "\n\n"
    1.22 ++//usage:       "Bring the system down\n"
    1.23 ++//usage:     "\n	-r	Do reboot"
    1.24 ++//usage:     "\n	-h	Do poweroff"
    1.25 ++//usage:     "\n	-H	Do halt"
    1.26 ++//usage:     "\n	-P	Do poweroff"
    1.27 + 
    1.28 + #include "libbb.h"
    1.29 + #include "reboot.h"
    1.30 +@@ -164,6 +174,7 @@
    1.31 + int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    1.32 + int halt_main(int argc UNUSED_PARAM, char **argv)
    1.33 + {
    1.34 ++	enum { HALT=0, POWEROFF=1, REBOOT=2, SHUTDOWN=3 };
    1.35 + 	static const int magic[] = {
    1.36 + 		RB_HALT_SYSTEM,
    1.37 + 		RB_POWER_OFF,
    1.38 +@@ -184,15 +195,26 @@
    1.39 + 	if (!ENABLE_HALT && !ENABLE_POWEROFF && ENABLE_REBOOT)
    1.40 + 		which = 2;
    1.41 + 	else
    1.42 +-	for (which = 0; "hpr"[which] != applet_name[0]; which++)
    1.43 ++	for (which = 0; "hprs"[which] != applet_name[0]; which++)
    1.44 + 		continue;
    1.45 + 
    1.46 ++	if (which == SHUTDOWN) {
    1.47 ++		which = REBOOT;
    1.48 ++		switch (getopt32(argv, "rhPH")) {
    1.49 ++			case 2:
    1.50 ++			case 4: which = POWEROFF; break;
    1.51 ++			case 8: which = HALT;
    1.52 ++		}
    1.53 ++		flags = 0;
    1.54 ++	}
    1.55 ++	else {
    1.56 + 	/* Parse and handle arguments */
    1.57 + 	/* We support -w even if !ENABLE_FEATURE_WTMP,
    1.58 + 	 * in order to not break scripts.
    1.59 + 	 * -i (shut down network interfaces) is ignored.
    1.60 + 	 */
    1.61 + 	flags = getopt32(argv, "d:+nfwi", &delay);
    1.62 ++	}
    1.63 + 
    1.64 + 	sleep(delay);
    1.65 +