diff --recursive --unified sysvinit-2.76-old/man/shutdown.8 sysvinit-2.76/man/shutdown.8 --- sysvinit-2.76-old/man/shutdown.8 Mon Jun 22 12:43:59 1998 +++ sysvinit-2.76/man/shutdown.8 Mon Jan 25 22:52:44 1999 @@ -11,7 +11,7 @@ .B /sbin/shutdown .RB [ \-t .IR sec ] -.RB [ \-arkhncfF ] +.RB [ \-arkhpncfF ] .I time .RI [ warning-message ] .\"}}} @@ -56,6 +56,11 @@ .IP \fB\-h\fP Halt after shutdown. .\"}}} +.\"{{{ -p +.IP \fB\-p\fP +Power off after halt. Note that this won't work together with -n (which +you shouldn't use anyway). +.\"}}} .\"{{{ -n .IP \fB\-n\fP [DEPRECATED] Don't call \fBinit\fP(8) to do the shutdown but do it ourself. @@ -111,6 +116,11 @@ to run \fBfsck\fP(1) with a special `force' flag so that even properly unmounted filesystems get checked. After that, the boot process should remove \fI/forcefsck\fP. +.PP +The \fB-p\fP flag causes \fBshutdown\fP to create a file +\fI/poweroff\fP which tells halt to power off. When halt checks for this +file, the filesystem should be read-only, so halt can't delete it. +\fBshutdown\fP will delete this file the next time, it's run. .PP The \fB-n\fP flag causes \fBshutdown\fP not to call \fBinit\fP, but to kill all running processes itself. diff --recursive --unified sysvinit-2.76-old/src/halt.c sysvinit-2.76/src/halt.c --- sysvinit-2.76-old/src/halt.c Mon Mar 9 21:08:38 1998 +++ sysvinit-2.76/src/halt.c Mon Jan 25 22:50:28 1999 @@ -46,6 +46,7 @@ #include #include #include "reboot.h" +#include "paths.h" char *Version = "@(#)halt 2.74 24-Feb-1998 miquels@cistron.nl"; char *progname; @@ -161,6 +162,7 @@ int do_poweroff = 0; int c; char *tm = NULL; + int p; /* * Find out who we are @@ -219,7 +221,23 @@ */ c = get_runlevel(); if (c != '0' && c != '6') - do_shutdown(do_reboot ? "-r" : "-h", tm); + do_shutdown(do_reboot ? "-r" : (do_poweroff ? "-p" : "-h"), tm); + } + + /* + * Unless we're forcing the halt, check for existence of /poweroff + */ + + if (!do_hard) { + p = open(POWEROFF, O_RDONLY); + if (p > 0) { + close(p); + /* POWEROFF should be deleted now, but the + * filesystem is probably read-only, so we + * can't. Instead it's done in shutdown. + */ + do_poweroff=1; + } } /* diff --recursive --unified sysvinit-2.76-old/src/paths.h sysvinit-2.76/src/paths.h --- sysvinit-2.76-old/src/paths.h Wed Nov 26 15:23:12 1997 +++ sysvinit-2.76/src/paths.h Mon Jan 25 22:50:28 1999 @@ -25,6 +25,7 @@ #define NOLOGIN "/etc/nologin" /* Stop user logging in. */ #define FASTBOOT "/fastboot" /* Enable fast boot. */ #define FORCEFSCK "/forcefsck" /* Force fsck on boot */ +#define POWEROFF "/poweroff" /* Power off after halt */ #define SDPID "/var/run/shutdown.pid" /* PID of shutdown program */ #define IOSAVE "/etc/ioctl.save" /* termios settings for SU */ #define SHELL "/bin/sh" /* Default shell */ diff --recursive --unified sysvinit-2.76-old/src/shutdown.c sysvinit-2.76/src/shutdown.c --- sysvinit-2.76-old/src/shutdown.c Sun May 10 10:33:40 1998 +++ sysvinit-2.76/src/shutdown.c Mon Jan 25 22:51:39 1999 @@ -5,6 +5,7 @@ * -k: don't really shutdown, only warn. * -r: reboot after shutdown. * -h: halt after shutdown. + * -p: power off after halt. * -f: do a 'fast' reboot (skip fsck). * -F: Force fsck on reboot. * -n: do not go through init but do it ourselves. @@ -46,6 +47,7 @@ int dosync = 1; /* Sync before reboot or halt */ int fastboot = 0; /* Do a 'fast' reboot */ int forcefsck = 0; /* Force fsck on reboot */ +int poweroff = 0; /* Power off after halt */ char message[MESSAGELEN]; /* Warning message */ char *sltime = 0; /* Sleep time */ char newstate[64]; /* What are we gonna do */ @@ -79,6 +81,7 @@ unlink(NOLOGIN); unlink(FASTBOOT); unlink(FORCEFSCK); + unlink(POWEROFF); unlink(SDPID); printf("\r\nShutdown cancelled.\r\n"); exit(0); @@ -95,6 +98,7 @@ "\t\t -k: don't really shutdown, only warn.\n" "\t\t -r: reboot after shutdown.\n" "\t\t -h: halt after shutdown.\n" + "\t\t -p: power off after halt.\n" "\t\t -f: do a 'fast' reboot (skip fsck).\n" "\t\t -F: Force fsck on reboot.\n" "\t\t -n: do not go through \"init\" but go down real fast.\n" @@ -218,6 +222,8 @@ /* We're done, halt or reboot now. */ if (do_halt) { fprintf(stderr, "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n"); +/* if (poweroff) */ +/* init_reboot(BMAGIC_POWEROFF); */ init_reboot(BMAGIC_HALT); exit(0); } @@ -263,6 +269,7 @@ unlink(FASTBOOT); unlink(FORCEFSCK); unlink(NOLOGIN); + unlink(POWEROFF); exit(1); } @@ -293,6 +300,7 @@ struct utmp *ut; int user_ok = 0; struct sigaction sa; + int p; /* We can be installed setuid root (executable for a special group) */ realuid = getuid(); @@ -305,7 +313,7 @@ strcpy(down_level, "1"); /* Process the options. */ - while((c = getopt(argc, argv, "acqkrhnfFyt:g:i:")) != EOF) { + while((c = getopt(argc, argv, "acqkrphnfFyt:g:i:")) != EOF) { switch(c) { case 'a': /* Access control. */ useacl = 1; @@ -319,6 +327,8 @@ case 'r': /* Automatic reboot */ down_level[0] = '6'; break; + case 'p': /* Poweroff */ + poweroff = 1; case 'h': /* Halt after shutdown */ down_level[0] = '0'; break; @@ -493,6 +503,16 @@ chdir("/"); if (fastboot) close(open(FASTBOOT, O_CREAT | O_RDWR, 0644)); if (forcefsck) close(open(FORCEFSCK, O_CREAT | O_RDWR, 0644)); + if (poweroff) { + close(open(POWEROFF, O_CREAT | O_RDWR, 0644)); + } else { + p = open(POWEROFF, O_RDONLY); + if (p > 0) { + close(p); + /* We delete POWEROFF here (it can't be done in halt) */ + unlink(POWEROFF); + } + } /* Alias now and take care of old '+mins' notation. */ if (!strcmp(when, "now")) strcpy(when, "0");