9e9a57a307
If we panic again shortly after boot (say, within 30 seconds), any core dump we wrote out may be lost on reboot. In this situation, we really want to keep that core file, as it may be the only way to have the issue resolved. Call sync(8) after writing out the core file and running crashinfo(8), in the hope that these will not be lost if we panic again. sync(8) is only called in the case where there is a core dump to be written out, so won't be called during normal boots. Discovered by: Trying to debug an IPSEC panic MFC after: 1 week
81 lines
1.2 KiB
Bash
Executable File
81 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: savecore
|
|
# REQUIRE: dumpon ddb syslogd
|
|
# KEYWORD: nojail
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="savecore"
|
|
start_cmd="savecore_start"
|
|
start_precmd="savecore_prestart"
|
|
stop_cmd=":"
|
|
|
|
savecore_prestart()
|
|
{
|
|
# Quit if we have no dump device
|
|
case ${dumpdev} in
|
|
[Nn][Oo] | '')
|
|
debug 'No dump device. Quitting.'
|
|
return 1
|
|
;;
|
|
[Aa][Uu][Tt][Oo])
|
|
if [ ! -L /dev/dumpdev ]; then
|
|
return 1
|
|
fi
|
|
dumpdev=`/bin/realpath /dev/dumpdev`
|
|
;;
|
|
esac
|
|
|
|
# If there is no crash directory set it now
|
|
case ${dumpdir} in
|
|
'')
|
|
dumpdir='/var/crash'
|
|
;;
|
|
[Nn][Oo])
|
|
dumpdir='NO'
|
|
;;
|
|
esac
|
|
|
|
if [ ! -c "${dumpdev}" ]; then
|
|
warn "Dump device does not exist. Savecore not run."
|
|
return 1
|
|
fi
|
|
|
|
if [ ! -d "${dumpdir}" ]; then
|
|
warn "Dump directory does not exist. Savecore not run."
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
savecore_start()
|
|
{
|
|
local dev
|
|
|
|
case "${dumpdev}" in
|
|
[Aa][Uu][Tt][Oo])
|
|
dev=
|
|
;;
|
|
*)
|
|
dev="${dumpdev}"
|
|
;;
|
|
esac
|
|
|
|
if savecore -C "${dev}" >/dev/null; then
|
|
savecore ${savecore_flags} ${dumpdir} ${dumpdev}
|
|
if checkyesno crashinfo_enable; then
|
|
${crashinfo_program} -d ${dumpdir}
|
|
fi
|
|
sync
|
|
else
|
|
check_startmsgs && echo 'No core dumps found.'
|
|
fi
|
|
}
|
|
|
|
load_rc_config $name
|
|
run_rc_command "$1"
|