From 7d537978612d2639cee753072801ad53f2d8bc26 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 11 Mar 2009 23:22:57 +0000 Subject: [PATCH] Switch the default value (if no options DDB_ONPANIC is defined) for ddb.onpanic to 1, change it back to 0 in sysctl.conf and make sure postinstall installs this setting. This avoids us trying to dump while booting from install CD, but keeps the default the same once we are far enough through /etc/rc.d. Failing earlier is unlikely to be recovered by an automatic reboot. OK: core. --- etc/sysctl.conf | 10 +++++++++- sys/ddb/db_variables.c | 6 +++--- usr.sbin/postinstall/postinstall | 31 ++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/etc/sysctl.conf b/etc/sysctl.conf index 83b0447d1cad..ae7776c81645 100644 --- a/etc/sysctl.conf +++ b/etc/sysctl.conf @@ -1,9 +1,17 @@ #!/sbin/sysctl -f # -# $NetBSD: sysctl.conf,v 1.5 2003/11/03 15:12:06 briggs Exp $ +# $NetBSD: sysctl.conf,v 1.6 2009/03/11 23:22:57 martin Exp $ # # sysctl(8) variables to set at boot time. +# Default on panic: dump core and reboot. See savecore(8) for information. +# Switch this to 1 if you want to enter the kernel debugger on crashes +# instead. See ddb(4) for an introduction and also try the "help" command +# at the db> prompt. +# If you understand the implication and want to change the behaviour before +# /etc/rc.d/sysctl is run, use the kernel option DDB_ONPANIC, see options(4). +ddb.onpanic=0 + # Default core name template: #kern.defcorename=%n.core diff --git a/sys/ddb/db_variables.c b/sys/ddb/db_variables.c index 0889bc08fbc6..7fdf5b9c15b1 100644 --- a/sys/ddb/db_variables.c +++ b/sys/ddb/db_variables.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_variables.c,v 1.41 2009/03/07 22:02:17 ad Exp $ */ +/* $NetBSD: db_variables.c,v 1.42 2009/03/11 23:22:57 martin Exp $ */ /* * Mach Operating System @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.41 2009/03/07 22:02:17 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.42 2009/03/11 23:22:57 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ddbparam.h" @@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.41 2009/03/07 22:02:17 ad Exp $") * panics. Initialize it so that it's patchable. */ #ifndef DDB_ONPANIC -#define DDB_ONPANIC 0 +#define DDB_ONPANIC 1 #endif int db_onpanic = DDB_ONPANIC; diff --git a/usr.sbin/postinstall/postinstall b/usr.sbin/postinstall/postinstall index e8fe48924f5d..8955bdee71a8 100755 --- a/usr.sbin/postinstall/postinstall +++ b/usr.sbin/postinstall/postinstall @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: postinstall,v 1.90 2009/02/26 10:32:43 apb Exp $ +# $NetBSD: postinstall,v 1.91 2009/03/11 23:22:57 martin Exp $ # # Copyright (c) 2002-2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -662,6 +662,35 @@ do_bluetooth() return ${failed} } +# +# ddbonpanic +# +additem ddbonpanic "verify ddb.onpanic is configured in sysctl.conf" +do_ddbonpanic() +{ + [ -n "$1" ] || err 3 "USAGE: do_ddbonpanic fix|check" + + if ${GREP} -E '^[[:space:]]*ddb\.onpanic[[:space:]]*=[[:space:]]*[[:digit:]]+' \ + "${DEST_DIR}/etc/sysctl.conf" >/dev/null 2>&1 + then + result=0 + else + if [ "$1" = check ]; then + msg \ + "The ddb.onpanic behaviour is not explicitly specified in /etc/sysctl.conf" + result=1 + else + echo >> "${DEST_DIR}/etc/sysctl.conf" + sed < "${SRC_DIR}/etc/sysctl.conf" \ + -e '/^ddb\.onpanic/q' | \ + sed -e '1,/^$/d' >> \ + "${DEST_DIR}/etc/sysctl.conf" + result=$? + fi + fi + return ${result} +} + # # defaults #