Date: Sat, 19 Sep 1998 12:25:33 -0700 (MST) From: neal@wanlink.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: kern/7990: patch - teach kernel about RB_POWEROFF flag, and /sbin/shutdown about halt -lp Message-ID: <199809191925.MAA14666@wan2.wanlink.com>
next in thread | raw e-mail | index | archive | help
>Number: 7990 >Category: kern >Synopsis: patch - teach kernel about RB_POWEROFF flag, and /sbin/shutdown about halt -lp >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Sep 19 12:30:00 PDT 1998 >Last-Modified: >Originator: Neal Horman >Organization: wanlink >Release: FreeBSD Current >Environment: FreeBSD Current >Description: Teach the kernel when to call cpu_power_down via the RB_POWEROFF FLAG, and /sbin/shutdown about -p which then calls halt with -lp instead of -l. Updated the shutdown man page as well. Files patched; /sys/kern/kern_shutdown.c /usr/sbin/shutdown/shutdown.c /usr/sbin/shutdown/shutdown.8 >How-To-Repeat: Installation Instructions; 1. copy the text from the "Fix:" section into a file called "powerdown.seta". 2. execute the script with "sh powerdown.seta -p", which will extract the patches into seperate "diff" files, and then call patch for you. 3. cd /usr/src/sbin/shutdown 4. make clean all install clean 5. recompile your kernel, and reboot. Note: for i386 you must have the apm bios options enabled in your kernel config file. >Fix: #!/bin/sh # # This is a SETA (self extracting text archive), and can be # executed by "sh powerdown.seta" at the command line. # Any text above the "#!/bin/sh" line should be removed! # PATCHIT="NO"; MAKEIT="NO" if [ "$1" = "-p" ]; then PATCHIT="YES"; shift; fi if [ "$1" = "-m" ]; then MAKEIT="YES"; shift; fi # ----- start of kern_shutdown.c.diff ----- cat <<SETAEOF |sed -e's/^S //g'>kern_shutdown.c.diff S *** /usr/src/sys/kern/kern_shutdown.c Sat Sep 5 23:25:04 1998 S --- ./kern_shutdown.c Sat Sep 19 11:09:49 1998 S *************** S *** 267,276 **** S } S splhigh(); S if (howto & RB_HALT) { S - cpu_power_down(); S printf("\n"); S printf("The operating system has halted.\n"); S ! printf("Please press any key to reboot.\n\n"); S switch (cngetc()) { S case -1: /* No console, just die */ S cpu_halt(); S --- 267,282 ---- S } S splhigh(); S if (howto & RB_HALT) { S printf("\n"); S printf("The operating system has halted.\n"); S ! if(howto & RB_POWEROFF) { /* honor 'halt/shutdown -p' */ S ! printf("Attempting system power off...\n"); S ! DELAY(3000000); /* give user time to see what just printed */ S ! cpu_power_down(); S ! DELAY(5000000); /* delay just incase power down task is async. */ S ! printf("System power off failure...\n\nPlease turn power off, or press any key to reboot.\n\n"); S ! } S ! else printf("Please press any key to reboot.\n\n"); S switch (cngetc()) { S case -1: /* No console, just die */ S cpu_halt(); SETAEOF if [ "$PATCHIT" = "YES" ]; then patch -l /usr/src/sys/kern/kern_shutdown.c < kern_shutdown.c.diff; fi # ----- end of kern_shutdown.c.diff ----- # ----- start of shutdown.8.diff ----- cat <<SETAEOF |sed -e's/^S //g'>shutdown.8.diff S *** /usr/src/sbin/shutdown/shutdown.8 Thu Jul 3 23:35:19 1997 S --- shutdown.8 Fri Aug 7 21:46:39 1998 S *************** S *** 40,46 **** S .Sh SYNOPSIS S .Nm shutdown S .Op Fl S ! .Op Fl hkrn S .Ar time S .Op Ar warning-message ... S .Sh DESCRIPTION S --- 40,46 ---- S .Sh SYNOPSIS S .Nm shutdown S .Op Fl S ! .Op Fl hkrnp S .Ar time S .Op Ar warning-message ... S .Sh DESCRIPTION S *************** S *** 59,64 **** S --- 59,72 ---- S .Nm shutdown S execs S .Xr halt 8 . S + .It Fl p S + The system is halted at the specified S + .Ar time S + when S + .Nm shutdown S + execs S + .Xr halt 8 S + with a -p option to try and power down the system. S .It Fl k S Kick every body off. S The SETAEOF if [ "$PATCHIT" = "YES" ]; then patch -l /usr/src/sbin/shutdown/shutdown.8 < shutdown.8.diff; fi # ----- end of shutdown.8.diff ----- # ----- start of shutdown.c.diff ----- cat <<SETAEOF |sed -e's/^S //g'>shutdown.c.diff S *** /usr/src/sbin/shutdown/shutdown.c Sat Sep 19 11:20:07 1998 S --- ./shutdown.c Sat Sep 19 11:35:26 1998 S *************** S *** 93,99 **** S #undef S S S static time_t offset, shuttime; S ! static int dohalt, doreboot, killflg, mbuflen; S static char *nosync, *whom, mbuf[BUFSIZ]; S S void badtime __P((void)); S --- 93,99 ---- S #undef S S S static time_t offset, shuttime; S ! static int dohalt, doreboot, killflg, mbuflen, dopowerdown; S static char *nosync, *whom, mbuf[BUFSIZ]; S S void badtime __P((void)); S *************** S *** 121,127 **** S #endif S nosync = NULL; S readstdin = 0; S ! while ((ch = getopt(argc, argv, "-hknr")) != -1) S switch (ch) { S case '-': S readstdin = 1; S --- 121,127 ---- S #endif S nosync = NULL; S readstdin = 0; S ! while ((ch = getopt(argc, argv, "-hknrp")) != -1) S switch (ch) { S case '-': S readstdin = 1; S *************** S *** 138,143 **** S --- 138,147 ---- S case 'r': S doreboot = 1; S break; S + case 'p': S + dopowerdown = 1; S + dohalt = 1; S + break; S case '?': S default: S usage(); S *************** S *** 152,157 **** S --- 156,166 ---- S warnx("incompatible switches -h and -r"); S usage(); S } S + S + if (dopowerdown && doreboot) { S + warnx("incompatible switches -p and -r."); S + usage(); S + } S getoffset(*argv++); S S if (*argv) { S *************** S *** 337,344 **** S #ifdef DEBUG S if (doreboot) S (void)printf("reboot"); S ! else if (dohalt) S ! (void)printf("halt"); S if (nosync) S (void)printf(" no sync"); S (void)printf("\nkill -HUP 1\n"); S --- 346,357 ---- S #ifdef DEBUG S if (doreboot) S (void)printf("reboot"); S ! else if (dohalt) { S ! if(dopowerdown S ! (void)printf("halt w/powerdown"); S ! else S ! (void)printf("halt"); S ! } S if (nosync) S (void)printf(" no sync"); S (void)printf("\nkill -HUP 1\n"); S *************** S *** 349,360 **** S syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT); S warn(_PATH_REBOOT); S } S ! else if (dohalt) { S ! execle(_PATH_HALT, "halt", "-l", nosync, S ! (char *)NULL, empty_environ); S ! syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); S warn(_PATH_HALT); S ! } S (void)kill(1, SIGTERM); /* to single user */ S #endif S finish(0); S --- 362,377 ---- S syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT); S warn(_PATH_REBOOT); S } S ! else if (dohalt) { S ! if(dopowerdown) S ! execle(_PATH_HALT, "halt", "-lp", nosync, S ! (char *)NULL, empty_environ); S ! else S ! execle(_PATH_HALT, "halt", "-l", nosync, S ! (char *)NULL, empty_environ); S ! syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); S warn(_PATH_HALT); S ! } S (void)kill(1, SIGTERM); /* to single user */ S #endif S finish(0); SETAEOF if [ "$PATCHIT" = "YES" ]; then patch -l /usr/src/sbin/shutdown/shutdown.c < shutdown.c.diff; fi # ----- end of shutdown.c.diff ----- if [ "$MAKEIT" = "YES" ]; then make; fi # MAKEIT >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809191925.MAA14666>