After upgrading to linux-2.1.97 I noticed that the poweroff feature of
Linux no longer worked (i.e.. a "poweroff" or "halt -p" only shuts the
system down). This used to work with Linux-2.0.x so I first thought it
would be a kernel bug. After some investigation I found that this was
due to the different handling of the ARM options in the kernel. I got
it working again by patching SysVinit-2.74. Although this is not a
kernel patch, it's closely related to the new kernel and I would like
to get some beta testers for my patch.
--- sysvinit-2.74/src/halt.c.orig Sun Apr 19 13:22:06 1998
+++ sysvinit-2.74/src/halt.c Sun Apr 19 23:41:29 1998
@@ -45,6 +45,7 @@
#include <signal.h>
#include <stdio.h>
#include <getopt.h>
+#include "paths.h"
#include "reboot.h"
char *Version = "@(#)halt 2.74 24-Feb-1998 miquels@cistron.nl";
@@ -219,7 +220,9 @@
*/
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);
}
/*
@@ -258,6 +261,10 @@
/*
* Halt or poweroff.
*/
+ if (access(POWEROFF, F_OK) == 0) {
+ unlink(POWEROFF);
+ do_poweroff = 1;
+ }
if (do_poweroff)
init_reboot(BMAGIC_POWEROFF);
/*
--- sysvinit-2.74/src/shutdown.c.orig Sun Apr 19 18:48:39 1998
+++ sysvinit-2.74/src/shutdown.c Sun Apr 19 23:41:06 1998
@@ -1,9 +1,10 @@
/*
* shutdown.c Shut the system down.
*
- * Usage: shutdown [-krhfnc] time [warning message]
+ * Usage: shutdown [-krphfFnc] [-t <secs>] time [warning message]
* -k: don't really shutdown, only warn.
* -r: reboot after shutdown.
+ * -p: poweroff after shutdown.
* -h: halt after shutdown.
* -f: do a 'fast' reboot (skip fsck).
* -F: Force fsck on reboot.
@@ -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; /* Poweroff on halt */
char message[MESSAGELEN]; /* Warning message */
char *sltime = 0; /* Sleep time */
char newstate[64]; /* What are we gonna do */
@@ -93,6 +95,7 @@
"Usage:\t shutdown [-krhfnc] [-t secs] time [warning message]\n"
"\t\t -k: don't really shutdown, only warn.\n"
"\t\t -r: reboot after shutdown.\n"
+ "\t\t -p: poweroff after shutdown.\n"
"\t\t -h: halt after shutdown.\n"
"\t\t -f: do a 'fast' reboot (skip fsck).\n"
"\t\t -F: Force fsck on reboot.\n"
@@ -351,7 +354,7 @@
}
/* Process the options. */
- while((c = getopt(argc, argv, "cqkrhnfFyt:g:i:")) != EOF) {
+ while((c = getopt(argc, argv, "cqkrphnfFyt:g:i:")) != EOF) {
switch(c) {
case 'c': /* Cancel an already running shutdown. */
cancel = 1;
@@ -362,6 +365,9 @@
case 'r': /* Automatic reboot */
down_level[0] = '6';
break;
+ case 'p': /* Poweroff after shutdown */
+ poweroff = 1;
+ /* Fallthrough */
case 'h': /* Halt after shutdown */
down_level[0] = '0';
break;
@@ -487,6 +493,7 @@
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));
/* Alias now and take care of old '+mins' notation. */
if (!strcmp(when, "now")) strcpy(when, "0");
--- sysvinit-2.74/src/paths.h.orig Wed Nov 26 15:23:12 1997
+++ sysvinit-2.74/src/paths.h Sun Apr 19 22:47:29 1998
@@ -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" /* Force poweroff on 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 */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu