svn commit: r319477 - in head: etc/rc.d usr.sbin/crashinfo

Eric van Gyzen vangyzen at FreeBSD.org
Thu Jun 1 21:23:05 UTC 2017


Author: vangyzen
Date: Thu Jun  1 21:23:04 2017
New Revision: 319477
URL: https://svnweb.freebsd.org/changeset/base/319477

Log:
  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

Modified:
  head/etc/rc.d/savecore
  head/usr.sbin/crashinfo/crashinfo.8
  head/usr.sbin/crashinfo/crashinfo.sh

Modified: head/etc/rc.d/savecore
==============================================================================
--- head/etc/rc.d/savecore	Thu Jun  1 21:20:44 2017	(r319476)
+++ head/etc/rc.d/savecore	Thu Jun  1 21:23:04 2017	(r319477)
@@ -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

Modified: head/usr.sbin/crashinfo/crashinfo.8
==============================================================================
--- head/usr.sbin/crashinfo/crashinfo.8	Thu Jun  1 21:20:44 2017	(r319476)
+++ head/usr.sbin/crashinfo/crashinfo.8	Thu Jun  1 21:23:04 2017	(r319477)
@@ -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

Modified: head/usr.sbin/crashinfo/crashinfo.sh
==============================================================================
--- head/usr.sbin/crashinfo/crashinfo.sh	Thu Jun  1 21:20:44 2017	(r319476)
+++ head/usr.sbin/crashinfo/crashinfo.sh	Thu Jun  1 21:23:04 2017	(r319477)
@@ -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", osreleas
 version=$(gdb_command $KERNEL 'printf "%s", version' | tr '\t\n' '  ')
 machine=$(gdb_command $KERNEL 'printf "%s", machine')
 
-exec > $FILE 2>&1
+if ! $BATCH; then
+	echo "Writing crash summary to $FILE."
+	exec > $FILE 2>&1
+fi
 
 echo "$HOSTNAME dumped core - see $VMCORE"
 echo


More information about the svn-src-head mailing list