summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1999-01-30 19:28:30 +0000
committermsmith <msmith@FreeBSD.org>1999-01-30 19:28:30 +0000
commit8e7d737e1529ec05f41fa42a89ccb5a91f68d23f (patch)
tree49bed3cdc8ad6ce2776e369cec384883bf6d995f /sys
parent934d12e73e08297f16fe11dc488fd037a4546750 (diff)
downloadFreeBSD-src-8e7d737e1529ec05f41fa42a89ccb5a91f68d23f.zip
FreeBSD-src-8e7d737e1529ec05f41fa42a89ccb5a91f68d23f.tar.gz
Add a new sysctl node kern.shutdown, off which shutdown-related things
can be hung. Add a tunable delay at the beginning of the SHUTDOWN_FINAL at_shutdown queue, allowing time to settle before we launch into the list of things that are expected to turn the system off. Fix a bug in at_shutdown_pri() where the second insertion always put the item in second position in the queue. Reviewed by: "D. Rock" <rock@cs.uni-sb.de>
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_shutdown.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 4d6db41..1083b6d 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
- * $Id: kern_shutdown.c,v 1.43 1998/12/04 22:54:51 archie Exp $
+ * $Id: kern_shutdown.c,v 1.44 1998/12/28 23:03:00 msmith Exp $
*/
#include "opt_ddb.h"
@@ -88,6 +88,8 @@ SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
&debugger_on_panic, 0, "");
#endif
+SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment");
+
#ifdef HW_WDOG
/*
* If there is a hardware watchdog, point this at the function needed to
@@ -470,7 +472,7 @@ at_shutdown(bootlist_fn function, void *arg, int queue)
int
at_shutdown_pri(bootlist_fn function, void *arg, int queue, int pri)
{
- sle_p ep, ip;
+ sle_p op, ep, ip;
if (queue < SHUTDOWN_PRE_SYNC
|| queue > SHUTDOWN_FINAL) {
@@ -492,7 +494,7 @@ at_shutdown_pri(bootlist_fn function, void *arg, int queue, int pri)
if (ip == NULL) {
LIST_INSERT_HEAD(&shutdown_lists[queue], ep, links);
} else {
- for (; LIST_NEXT(ip, links) != NULL; ip = LIST_NEXT(ip, links)) {
+ for (; ip != NULL; op = ip, ip = LIST_NEXT(ip, links)) {
if (ep->priority < ip->priority) {
LIST_INSERT_BEFORE(ip, ep, links);
ep = NULL;
@@ -500,7 +502,7 @@ at_shutdown_pri(bootlist_fn function, void *arg, int queue, int pri)
}
}
if (ep != NULL)
- LIST_INSERT_AFTER(ip, ep, links);
+ LIST_INSERT_AFTER(op, ep, links);
}
return (0);
}
@@ -528,3 +530,27 @@ rm_at_shutdown(bootlist_fn function, void *arg)
}
return (count);
}
+
+/*
+ * Support for poweroff delay.
+ */
+static int poweroff_delay = 0;
+SYSCTL_INT(_kern_shutdown, OID_AUTO, poweroff_delay, CTLFLAG_RW,
+ &poweroff_delay, 0, "");
+
+static void poweroff_wait(int howto, void *unused)
+{
+ if(!(howto & RB_POWEROFF) || poweroff_delay <= 0)
+ return;
+ DELAY(poweroff_delay * 1000);
+}
+
+/*
+ * XXX OK? This implies I know SHUTDOWN_PRI_LAST > SHUTDOWN_PRI_FIRST
+ */
+static void poweroff_conf(void *unused)
+{
+ at_shutdown_pri(poweroff_wait, NULL, SHUTDOWN_FINAL, SHUTDOWN_PRI_FIRST);
+}
+
+SYSINIT(poweroff_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, poweroff_conf, NULL)
OpenPOWER on IntegriCloud