From dima@unixfreak.org  Thu Apr 12 01:05:17 2001
Return-Path: <dima@unixfreak.org>
Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138])
	by hub.freebsd.org (Postfix) with ESMTP id 916A637B621
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 12 Apr 2001 01:05:12 -0700 (PDT)
	(envelope-from dima@unixfreak.org)
Received: from hornet.unixfreak.org (hornet [63.198.170.140])
	by bazooka.unixfreak.org (Postfix) with ESMTP id E19883E25
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 12 Apr 2001 01:05:09 -0700 (PDT)
Received: (from dima@localhost)
	by hornet.unixfreak.org (8.11.1/8.11.1) id f3C858390387;
	Thu, 12 Apr 2001 01:05:08 -0700 (PDT)
	(envelope-from dima)
Message-Id: <200104120805.f3C858390387@hornet.unixfreak.org>
Date: Thu, 12 Apr 2001 01:05:08 -0700 (PDT)
From: dd@freebsd.org
Reply-To: dd@freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] fixes to dump(8)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         26507
>Category:       bin
>Synopsis:       [PATCH] fixes to dump(8)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 12 01:10:01 PDT 2001
>Closed-Date:    Fri Apr 20 01:11:31 PDT 2001
>Last-Modified:  Fri Apr 20 01:11:54 PDT 2001
>Originator:     Dima Dorfman
>Release:        FreeBSD 5.0-20010407-CURRENT i386
>Organization:
Private
>Environment:
System: FreeBSD spike.unixfreak.org 5.0-20010407-CURRENT FreeBSD 5.0-20010407-CURRENT #39: Sun Apr 8 22:44:22 PDT 2001 dima@spike.unixfreak.org:/c/home/dima/w/f/src/sys/compile/SPIKE i386

>Description:

Attached is a patch that makes some [relatively minor] fixes to
src/sbin/dump/traverse.c.  Most of these bugs were caused by incorrect
assumptions I made when porting over NetBSD's code to handle the
nodump filesystem flag on directories (revs. 1.12 and 1.10.2.2).

The first two hunks' purpose should be pretty obvious from the comment
update; basically, mapdirs() tests directory inodes for being in
dumpdirmap but not in usedinomap to detect whether that directory has
inherited, or has set, the nodump flag.  Currently, this test will
fail when it shouldn't when doing a dump with level > 0 and when no
directories on the filesystem were changed.

The third hunk corrects a small bogon with regards to handling the -h
option.

>How-To-Repeat:
>Fix:

Apply the following patch to src/sbin/dump/traverse.c:

Index: traverse.c
===================================================================
RCS file: /st/src/FreeBSD/src/sbin/dump/traverse.c,v
retrieving revision 1.12
diff -u -r1.12 traverse.c
--- traverse.c	2001/03/03 11:35:50	1.12
+++ traverse.c	2001/04/07 22:50:35
@@ -155,13 +155,15 @@
 		if ((mode = (dp->di_mode & IFMT)) == 0)
 			continue;
 		/*
-		 * All dirs go in dumpdirmap; only inodes that are to
-		 * be dumped go in usedinomap and dumpinomap, however.
+		 * Everything must go in usedinomap so that a check
+		 * for "in dumpdirmap but not in usedinomap" to detect
+		 * dirs with nodump set has a chance of succeeding
+		 * (this is used in mapdirs()).
 		 */
+		SETINO(ino, usedinomap);
 		if (mode == IFDIR)
 			SETINO(ino, dumpdirmap);
 		if (WANTTODUMP(dp)) {
-			SETINO(ino, usedinomap);
 			SETINO(ino, dumpinomap);
 			if (mode != IFREG && mode != IFDIR && mode != IFLNK)
 				*tapesize += 1;
@@ -169,8 +171,11 @@
 				*tapesize += blockest(dp);
 			continue;
 		}
-		if (mode == IFDIR)
+		if (mode == IFDIR) {
+			if (!nonodump && (dp->di_flags & UF_NODUMP))
+				CLRINO(ino, usedinomap);
 			anydirskipped = 1;
+		}
 	}
 	/*
 	 * Restore gets very upset if the root is not dumped,
@@ -218,7 +223,7 @@
 		 * it isn't in usedinomap, we have to go through it to
 		 * propagate the nodump flag.
 		 */
-		nodump = (TSTINO(ino, usedinomap) == 0);
+		nodump = !nonodump && (TSTINO(ino, usedinomap) == 0);
 		if ((isdir & 1) == 0 || (TSTINO(ino, dumpinomap) && !nodump))
 			continue;
 		dp = getino(ino);

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: dd 
State-Changed-When: Fri Apr 20 01:11:31 PDT 2001 
State-Changed-Why:  
Patch committed by jkh to both -current and -stable. 

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