mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-26 21:13:11 +01:00
crashinfo: add "batch" mode and use it during boot
In batch mode, most messages go into the core.txt.N file instead of stdout. Reviewed by: jhb MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10429
This commit is contained in:
parent
5acae76adf
commit
1f1ed24cc5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=319477
@ -70,7 +70,7 @@ savecore_start()
|
||||
if savecore -C "${dev}" >/dev/null; then
|
||||
savecore ${savecore_flags} ${dumpdir} ${dumpdev}
|
||||
if checkyesno crashinfo_enable; then
|
||||
${crashinfo_program} -d ${dumpdir}
|
||||
${crashinfo_program} -b -d ${dumpdir}
|
||||
fi
|
||||
sync
|
||||
else
|
||||
|
@ -27,7 +27,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 28, 2008
|
||||
.Dd April 19, 2017
|
||||
.Dt CRASHINFO 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -88,6 +88,12 @@ and
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl b
|
||||
Run in batch mode. Write most messages to the
|
||||
.Pa core.txt.XX
|
||||
file instead of the terminal. This flag is used when
|
||||
.Nm
|
||||
is run during boot.
|
||||
.It Fl d Ar crashdir
|
||||
Specify an alternate core dump directory.
|
||||
The default crash dump directory is
|
||||
|
@ -31,7 +31,8 @@
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "usage: crashinfo [-d crashdir] [-n dumpnr] [-k kernel] [core]"
|
||||
echo "usage: crashinfo [-b] [-d crashdir] [-n dumpnr]" \
|
||||
"[-k kernel] [core]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -93,12 +94,16 @@ find_kernel()
|
||||
done
|
||||
}
|
||||
|
||||
BATCH=false
|
||||
CRASHDIR=/var/crash
|
||||
DUMPNR=
|
||||
KERNEL=
|
||||
|
||||
while getopts "d:n:k:" opt; do
|
||||
while getopts "bd:n:k:" opt; do
|
||||
case "$opt" in
|
||||
b)
|
||||
BATCH=true
|
||||
;;
|
||||
d)
|
||||
CRASHDIR=$OPTARG
|
||||
;;
|
||||
@ -153,6 +158,11 @@ INFO=$CRASHDIR/info.$DUMPNR
|
||||
FILE=$CRASHDIR/core.txt.$DUMPNR
|
||||
HOSTNAME=`hostname`
|
||||
|
||||
if $BATCH; then
|
||||
echo "Writing crash summary to $FILE."
|
||||
exec > $FILE 2>&1
|
||||
fi
|
||||
|
||||
find_gdb
|
||||
if [ -z "$GDB" ]; then
|
||||
echo "Unable to find a kernel debugger."
|
||||
@ -181,8 +191,6 @@ elif [ ! -e $KERNEL ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Writing crash summary to $FILE."
|
||||
|
||||
umask 077
|
||||
|
||||
# Simulate uname
|
||||
@ -191,7 +199,10 @@ osrelease=$(gdb_command $KERNEL 'printf "%s", osrelease')
|
||||
version=$(gdb_command $KERNEL 'printf "%s", version' | tr '\t\n' ' ')
|
||||
machine=$(gdb_command $KERNEL 'printf "%s", machine')
|
||||
|
||||
if ! $BATCH; then
|
||||
echo "Writing crash summary to $FILE."
|
||||
exec > $FILE 2>&1
|
||||
fi
|
||||
|
||||
echo "$HOSTNAME dumped core - see $VMCORE"
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user