From gleb.kurtsou@gmail.com  Sat Jun 28 23:54:20 2008
Return-Path: <gleb.kurtsou@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 111131065674
	for <bug-followup@freebsd.org>; Sat, 28 Jun 2008 23:54:20 +0000 (UTC)
	(envelope-from gleb.kurtsou@gmail.com)
Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.188])
	by mx1.freebsd.org (Postfix) with ESMTP id 8B47D8FC19
	for <bug-followup@freebsd.org>; Sat, 28 Jun 2008 23:54:19 +0000 (UTC)
	(envelope-from gleb.kurtsou@gmail.com)
Received: by fk-out-0910.google.com with SMTP id k31so970180fkk.11
        for <bug-followup@freebsd.org>; Sat, 28 Jun 2008 16:54:18 -0700 (PDT)
Received: by 10.78.142.14 with SMTP id p14mr900129hud.51.1214695709475;
        Sat, 28 Jun 2008 16:28:29 -0700 (PDT)
Received: from localhost ( [213.184.224.35])
        by mx.google.com with ESMTPS id 36sm3199032hub.59.2008.06.28.16.28.25
        (version=SSLv3 cipher=RC4-MD5);
        Sat, 28 Jun 2008 16:28:26 -0700 (PDT)
Message-Id: <20080628233530.GA1291@h1.d>
Date: Sun, 29 Jun 2008 02:35:30 +0300
From: Gleb Kurtsou <gleb.kurtsou@gmail.com>
To: Mike Makonnen <mtm@wubethiopia.com>
Cc: bug-followup@FreeBSD.org
In-Reply-To: <486158AF.2010909@wubethiopia.com>
Subject: Re: cvs commit: src/etc/rc.d savecore
References: <200806232054.m5NKsaRS025388@repoman.freebsd.org> <20080624174527.GA1400@h1.d> <486158AF.2010909@wubethiopia.com>

>Number:         125087
>Category:       conf
>Synopsis:       Re: cvs commit: src/etc/rc.d savecore
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 29 00:00:00 UTC 2008
>Closed-Date:    Sun Jun 29 10:13:24 UTC 2008
>Last-Modified:  Sun Jun 29 10:13:24 UTC 2008
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 On (24/06/2008 23:27), Mike Makonnen wrote:
 > Gleb Kurtsou wrote:
 >> On (23/06/2008 20:54), Mike Makonnen wrote:
 >>> mtm         2008-06-23 20:54:32 UTC
 >>> 
 >>>   FreeBSD src repository
 >>> 
 >>>   Modified files:
 >>>     etc/rc.d             savecore   Log:
 >>>   SVN rev 179962 on 2008-06-23 20:54:32Z by mtm
 >>>     Run savecore(8) only if there is a core dump to save. If there is
 >>>   no core dump hide the message to that effect behind $rc_quiet.
 >>>     Revision  Changes    Path
 >>>   1.13      +5 -2      src/etc/rc.d/savecore
 >> While you are working on rc.d scripts. Would you mind taking a look at
 >> conf/124747: [patch] savecore can't create dump from encrypted swap
 >> http://www.freebsd.org/cgi/query-pr.cgi?pr=124747
 > 
 > I've replied to the PR stating why I think the patch can't be committed as 
 > is. The savecore(8) program needs a filesystem to dump to, so it can't 
 > possibly be run before at least rc.d/mountcritlocal. The other option is to 
 > mount swap *after* savecore(8) has run, but that also has its own problems. 
 > I'm not sure what the right thing to do is...
 > 
 
 I didn't receive follow up to the pr. Hope this one will get through.
 
 I've come up with a better solution for a problem: get a dump first, and
 then call `savecore -c` to clear dump devices.
 The problem may arise if dump device is not used as a swap device or
 sector size of encrypted device differs from original sector size.
 Solution for the first case can be the following: call `savecore -c` on dump
 device first and then just `savecore -c` to clean up the rest.
 The second case can be difficult to work around. 
 
 If patch is ok for you, I'll work on it further.
 
 
 diff -r f93dd0cf22f5 etc/rc.d/savecore
 --- a/etc/rc.d/savecore	Sun Jun 29 02:15:41 2008 +0300
 +++ b/etc/rc.d/savecore	Sun Jun 29 02:17:18 2008 +0300
 @@ -58,7 +58,11 @@ savecore_start()
  savecore_start()
  {
  	echo "Checking for core dump on ${dumpdev}..."
 -	savecore ${savecore_flags} ${DUMPDIR} ${dumpdev}
 +	savecore -C ${DUMPDIR} ${dumpdev}
 +	if [ $? -eq 0 ]; then
 +		savecore ${savecore_flags} -k ${DUMPDIR} ${dumpdev}
 +		savecore -c
 +	fi
  }
  
  load_rc_config $name
 diff -r f93dd0cf22f5 sbin/savecore/savecore.c
 --- a/sbin/savecore/savecore.c	Sun Jun 29 02:15:41 2008 +0300
 +++ b/sbin/savecore/savecore.c	Sun Jun 29 02:17:18 2008 +0300
 @@ -389,7 +389,7 @@ DoFile(const char *savedir, const char *
  	if (verbose)
  		printf("checking for kernel dump on device %s\n", device);
  
 -	fd = open(device, O_RDWR);
 +	fd = open(device, (keep || checkfor ? O_RDONLY : O_RDWR));
  	if (fd < 0) {
  		syslog(LOG_ERR, "%s: %m", device);
  		return;
 @@ -450,6 +450,8 @@ DoFile(const char *savedir, const char *
  			    device);
  
  		status = STATUS_BAD;
 +		if (clear)
 +			goto nuke;
  		if (force == 0)
  			goto closefd;
  
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Jun 29 10:11:35 UTC 2008 
State-Changed-Why:  
Apparently a misfiled followup to conf/124747; content migrated. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Jun 29 10:11:35 UTC 2008 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=125087 
>Unformatted:
