NetBSD Problem Report #27274

Received: (qmail 2479 invoked by uid 605); 16 Oct 2004 07:23:41 -0000
Message-Id: <200410160723.i9G7NERT009334@apb-laptoy.apb.alt.za>
Date: Sat, 16 Oct 2004 09:23:14 +0200 (SAST)
From: Alan Barrett <apb@cequrux.com>
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: apb@cequrux.com
To: gnats-bugs@gnats.NetBSD.org
Subject: Keep RCS backups of dmesg.boot
X-Send-Pr-Version: 3.95

>Number:         27274
>Category:       misc
>Synopsis:       Keep RCS backups of dmesg.boot
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 16 07:24:00 +0000 2004
>Closed-Date:    
>Last-Modified:  Mon Mar 12 00:34:29 +0000 2018
>Originator:     Alan Barrett
>Release:        NetBSD 2.99.9
>Organization:
	Not much
>Environment:
Architecture: i386
Machine: i386
>Description:
	I have been using a modified version of /etc/rc.d/dmesg for
	about 20 months, to keep RCS backups of /var/run/dmesg.boot.

        It works, but it needs a bit of cleanup, and it would be better
        if some of the logic that is used by both this script and
        /etc/security were abstracted into functions in /etc/rc.subr.

>How-To-Repeat:
	Observe that /etc/security makes daily RCS backups of lots of
	stuff.

	Wish that similar backups of /var/run/dmesg.boot were made at
	every boot.

>Fix:
	Apply this patch.

Index: etc/rc.d/dmesg
--- etc/rc.d/dmesg	13 Aug 2004 18:08:03 -0000	1.9
+++ etc/rc.d/dmesg	16 Oct 2004 07:18:28 -0000
@@ -12,13 +12,48 @@
 name="dmesg"
 rcvar=$name
 dmesg_file="/var/run/dmesg.boot"
+backup_dir="${backup_dir:-/var/backups}"
+#work_dir="${backup_dir}/work"
+work_dir="${backup_dir}/${dmesg_file%/*}"
 start_cmd="do_dmesg"
 stop_cmd=":"

 do_dmesg()
 {
+	mkdir -p ${work_dir}
+	BASE=${dmesg_file##*/}
+	CUR=${work_dir}/${BASE}.current
+	BACK=${work_dir}/${BASE}.backup
+	#echo "start"
+	#ls -ld ${dmesg_file} ${CUR} ${CUR},v
+	# Backup the old file left over from the previous boot,
+	# if it was not already backed up.
+	if [ -f ${dmesg_file} ]; then
+		if [ -f $CUR ] && cmp -s ${dmesg_file} $CUR; then
+		    : OK
+		else
+		    echo "Backing up old ${dmesg_file} from previous boot."
+		    backup_file update ${dmesg_file} $CUR $BACK
+		fi
+	fi
+	#echo "saved old"
+	#ls -ld ${dmesg_file} ${CUR} ${CUR},v
+	# Create the new file.
 	rm -f ${dmesg_file}
 	( umask 022 ; /sbin/dmesg $rc_flags > ${dmesg_file} )
+	#echo "new"
+	#ls -ld ${dmesg_file} ${CUR} ${CUR},v
+	# Backup the new file, if it has changed.
+	if [ -f $CUR ] && cmp -s ${dmesg_file} $CUR; then
+	    : No changes
+	    echo "Not backing up unchanged ${dmesg_file}"
+	else
+	    #diff -u2 ${CUR} ${dmesg_file}
+	    echo "Backing up new ${dmesg_file}"
+	    backup_file update ${dmesg_file} $CUR $BACK
+	fi
+	#echo "end"
+	#ls -ld ${dmesg_file} ${CUR} ${CUR},v
 }

 load_rc_config $name
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: jdolecek 
State-Changed-When: Sat Oct 16 07:28:53 UTC 2004 
State-Changed-Why:  
While the purpose of keeping history of changes to system files is clear, 
I don't understand why you'd want to keep history of dmesg. Why would 
this be useful? 

From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@gnats.netbsd.org
Cc: jdolecek@netbsd.org, misc-bug-people@netbsd.org
Subject: Re: misc/27274
Date: Sat, 16 Oct 2004 09:51:57 +0200

 On Sat, 16 Oct 2004, jdolecek@netbsd.org wrote:
 > While the purpose of keeping history of changes to system files is clear,
 > I don't understand why you'd want to keep history of dmesg. Why would
 > this be useful?

 * When a new kernel causes some hardware to stop working, or when
   some swapped hardware doesn't work quite right, it's useful to have
   a log of what the device probe messages used to look like before
   the change.  (Just keeping one previous version of the file would
   probably be enough for most instances of this problem, but it was easy
   to leverage the existing RCS support.)

 * It's useful keeping a record of the dates of changes to hardware
   configurations and kernel versions.  Performance problems that are
   noticed long after the change can sometimes be correlated to specific
   changes.  (RCS backups allow history to be kept for a long time for
   this purpose.)

 --apb (Alan Barrett)
State-Changed-From-To: feedback->open 
State-Changed-By: jdolecek 
State-Changed-When: Sat Oct 16 13:25:52 UTC 2004 
State-Changed-Why:  
Such functionality might indeed be useful. Thanks for feedback. 
Responsible-Changed-From-To: misc-bug-people->apb
Responsible-Changed-By: apb@netbsd.org
Responsible-Changed-When: Sat, 07 Oct 2006 22:32:05 +0000
Responsible-Changed-Why:
I'll take this.


From: Elad Efrat <elad@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: misc/27274 (Keep RCS backups of dmesg.boot)
Date: Sun, 08 Oct 2006 01:07:53 +0200

 apb@netbsd.org wrote:
 > Synopsis: Keep RCS backups of dmesg.boot
 > 
 > Responsible-Changed-From-To: misc-bug-people->apb
 > Responsible-Changed-By: apb@netbsd.org
 > Responsible-Changed-When: Sat, 07 Oct 2006 22:32:05 +0000
 > Responsible-Changed-Why:
 > I'll take this.

 Might worth looking at PR/15629 too...

 -e.

 -- 
 Elad Efrat

Responsible-Changed-From-To: apb->misc-bug-people
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Mon, 12 Mar 2018 00:34:29 +0000
Responsible-Changed-Why:
Reset responsible field for retired developer.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.