Bug 35725

Summary: /etc/rc should create missing "dumpdir".
Product: Base System Reporter: Gary W. Swearingen <swear>
Component: confAssignee: Crist J. Clark <cjc>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.5-STABLE   
Hardware: Any   
OS: Any   

Description Gary W. Swearingen 2002-03-10 06:00:01 UTC
It is easy for one to follow the FAQ and man pages to configure for
crash dumps and fail to get the dump captured because the user didn't
know that the "dumpdir" needed to be pre-made, not just named in the
rc.config file.  I admit that it could be considered to be an implicit
requirement, but many will not think of it without a warning.

A good (?) and simple enhancement would be to have the code in /etc/rc
which checks for a missing "dumpdir" create it after it determines that
it is missing.  Or maybe the savecore(8) program should create the
directory that it is told to use (and the check removed from /etc/rc).
(I don't know if there's a conventional way for programs to handle
this situation.)

In any case, the savecore(8) man page and FAQ should describe the
requirement or lack thereof for the savecore(8) and the config
procedure, respectively.

P.S. I was lucky enough to have thought of the problem while examining
/etc/rc during crash-dump configuration.  I'm sure that many others will
not be so lucky; hence this change-request.
================

Fix: 

?
How-To-Repeat: n/a
================
Comment 1 Crist J. Clark freebsd_committer freebsd_triage 2002-03-10 22:07:51 UTC
On Sat, Mar 09, 2002 at 09:57:40PM -0800, Gary W. Swearingen wrote:
[snip]

> A good (?) and simple enhancement would be to have the code in /etc/rc
> which checks for a missing "dumpdir" create it after it determines that
> it is missing.

I don't think that is a good idea (what if $dumpdev was fat fingered
someplace is shouldn't be and say, filled up your root
filesystem). However, it currently fails silently, which I don't think
is good either. How about have rc(8) bitch about it,

Index: etc/rc
===================================================================
RCS file: /export/freebsd/ncvs/src/etc/rc,v
retrieving revision 1.296
diff -u -r1.296 rc
--- etc/rc	17 Feb 2002 22:19:14 -0000	1.296
+++ etc/rc	10 Mar 2002 22:02:56 -0000
@@ -554,10 +554,14 @@
 		;;
 	esac
 
-	if [ -e "${dumpdev}" -a -d "${dumpdir}" ]; then
+	if [ -e "${dumpdev}" ]; then
 		/sbin/dumpon -v ${dumpdev}
-		echo -n 'Checking for core dump: '
-		/sbin/savecore ${savecore_flags} "${dumpdir}"
+		if [ -d "${dumpdir}" ]; then
+			echo -n 'Checking for core dump: '
+			/sbin/savecore ${savecore_flags} "${dumpdir}"
+		else
+			echo "dumpdir directory does not exist: ${dumpdir}"
+		fi
 	fi
 	;;
 esac

-- 
Crist J. Clark                     |     cjclark@alum.mit.edu
                                   |     cjclark@jhu.edu
http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
Comment 2 Gary W. Swearingen 2002-03-10 23:00:19 UTC
"Crist J. Clark" <cjc@FreeBSD.ORG> writes:

> I don't think that is a good idea (what if $dumpdev was fat fingered
> someplace is shouldn't be and say, filled up your root
> filesystem). However, it currently fails silently, which I don't think
> is good either. How about have rc(8) bitch about it,

Sounds like you speak from experience.  I'll not argue with that.

We'll need to rely mostly on a good warning in the FAQ and man page(s).
Unless you educate me that I've got the PR SOP wrong, I'll write another
PR on the docs and leave this PR for your change to "/etc/rc".

Your patch looked good, except I'd prefer a stronger notice (of what
happened) to the person recovering from this intermittent crash he's
been awaiting for several days:

echo "NOTICE: Core dump was lost because '${dumpdir}' was not a directory."

But I guess he'll figure it out after not finding the dump files, so
either message provides a clue that should be good enough to let him
know it wasn't the software's fault that the files are missing.
Comment 3 crist.clark 2002-03-10 23:32:10 UTC
On Sun, Mar 10, 2002 at 03:00:19PM -0800, Gary W. Swearingen wrote:
> "Crist J. Clark" <cjc@FreeBSD.ORG> writes:
> 
> > I don't think that is a good idea (what if $dumpdev was fat fingered
> > someplace is shouldn't be and say, filled up your root
> > filesystem). However, it currently fails silently, which I don't think
> > is good either. How about have rc(8) bitch about it,
> 
> Sounds like you speak from experience.  I'll not argue with that.
> 
> We'll need to rely mostly on a good warning in the FAQ and man page(s).
> Unless you educate me that I've got the PR SOP wrong, I'll write another
> PR on the docs and leave this PR for your change to "/etc/rc".
> 
> Your patch looked good, except I'd prefer a stronger notice (of what
> happened) to the person recovering from this intermittent crash he's
> been awaiting for several days:
> 
> echo "NOTICE: Core dump was lost because '${dumpdir}' was not a directory."

But we don't know if a dump was lost or not. You'd see the error
everytime you booted. I'll word it more strongly, and I think perhaps
another check may be in order.
-- 
Crist J. Clark                     |     cjclark@alum.mit.edu
                                   |     cjclark@jhu.edu
http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
Comment 4 Crist J. Clark freebsd_committer freebsd_triage 2002-03-11 08:49:03 UTC
State Changed
From-To: open->analyzed

Why have /etc/rc check at all? Let savecore(8) run. It will complain 
loudly if given a bummer argument and behaves well. But provide a way 
to not have savecore(8) run when dumpdev is enabled. Committed to 
-CURRENT. 


Comment 5 Crist J. Clark freebsd_committer freebsd_triage 2002-03-11 08:49:03 UTC
Responsible Changed
From-To: freebsd-bugs->cjc

I'll handle MFC.
Comment 6 Crist J. Clark freebsd_committer freebsd_triage 2002-03-17 09:52:56 UTC
State Changed
From-To: analyzed->closed

MFC'ed to -STABLE.