From nobody@FreeBSD.org  Thu Sep 23 22:17:44 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id ED0FC1065673
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 23 Sep 2010 22:17:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id C10EA8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 23 Sep 2010 22:17:44 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8NMHi9W018894
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 23 Sep 2010 22:17:44 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o8NMHiKa018893;
	Thu, 23 Sep 2010 22:17:44 GMT
	(envelope-from nobody)
Message-Id: <201009232217.o8NMHiKa018893@www.freebsd.org>
Date: Thu, 23 Sep 2010 22:17:44 GMT
From: Tobias Herre <tobias.herre@srh-hochschule-berlin.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bsdtar does not always dive into subdirectories with --newerXXX option
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         150890
>Category:       bin
>Synopsis:       [patch] bsdtar(1) does not always dive into subdirectories with --newerXXX option
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kientzle
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 23 22:20:03 UTC 2010
>Closed-Date:    
>Last-Modified:  Sun Jun 26 18:00:01 UTC 2011
>Originator:     Tobias Herre
>Release:        FreeBSD 8.1
>Organization:
SRH Hochschule Berlin
>Environment:
grusel 8.1-STABLE FreeBSD 8.1-STABLE #1: Thu Sep 16 13:40:46 UTC 2010     root@grusel2.otauni.de:/usr/obj/usr/src/sys/SRHPOWER  amd64

>Description:
when --newerXXX option is given bsdtar ignores directory subtrees where modified or new files could exist if the parent directory is not modified. 


>How-To-Repeat:
grusel# mkdir -p test/txt
grusel# echo "Hello" > test/txt/hello.txt
grusel# tar -v -c -f archive0.tar test
a test
a test/txt
a test/txt/hello.txt
grusel# echo "World" >> test/txt/hello.txt
grusel# tar -v -c -f archive1.tar --newer-than archive0.tar test
grusel# tar -t -f archive0.tar 
test/
test/txt/
test/txt/hello.txt
grusel# tar -t -f archive1.tar
grusel# 

>Fix:
Apply the patch

Patch attached with submission follows:

--- usr.bin/tar/write.orig	2010-09-23 22:03:20.838021523 +0200
+++ usr.bin/tar/write.c	2010-09-23 22:54:58.985341640 +0200
@@ -752,13 +752,6 @@
 				descend = 0;
 		}
 
-		/*
-		 * In -u mode, check that the file is newer than what's
-		 * already in the archive; in all modes, obey --newerXXX flags.
-		 */
-		if (!new_enough(bsdtar, name, st))
-			continue;
-
 		archive_entry_free(entry);
 		entry = archive_entry_new();
 
@@ -813,7 +806,7 @@
 		 * check would veto this file, we shouldn't bother
 		 * the user with it.
 		 */
-		if (bsdtar->option_interactive &&
+		if (bsdtar->option_interactive && new_enough(bsdtar, name, st) &&
 		    !yes("add '%s'", name))
 			continue;
 
@@ -821,6 +814,15 @@
 		if (descend && !bsdtar->option_no_subdirs)
 			tree_descend(tree);
 
+
+		/*
+		 * In -u mode, check that the file is newer than what's
+		 * already in the archive; in all modes, obey --newerXXX flags.
+		 */
+		if (!new_enough(bsdtar, name, st))
+			continue;
+
+
 		/*
 		 * Rewrite the pathname to be archived.  If rewrite
 		 * fails, skip the entry.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kientzle 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Sep 26 21:13:03 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150890 
State-Changed-From-To: open->patched 
State-Changed-By: kientzle 
State-Changed-When: Sun Jun 26 17:56:14 UTC 2011 
State-Changed-Why:  
Fixed in -CURRENT r223573 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150890 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/150890: commit references a PR
Date: Sun, 26 Jun 2011 17:54:23 +0000 (UTC)

 Author: kientzle
 Date: Sun Jun 26 17:54:11 2011
 New Revision: 223573
 URL: http://svn.freebsd.org/changeset/base/223573
 
 Log:
   The --newer-than test should descend into old
   directories to look for new files.
   
   PR:		bin/150890
   Submitted by:	Tobias Herre
   MFC after:	3 weeks
 
 Modified:
   head/usr.bin/tar/write.c
 
 Modified: head/usr.bin/tar/write.c
 ==============================================================================
 --- head/usr.bin/tar/write.c	Sun Jun 26 17:30:46 2011	(r223572)
 +++ head/usr.bin/tar/write.c	Sun Jun 26 17:54:11 2011	(r223573)
 @@ -752,6 +752,9 @@ write_hierarchy(struct bsdtar *bsdtar, s
  			break;
  		}
  
 +		if (bsdtar->option_no_subdirs)
 +			descend = 0;
 +
  		/*
  		 * Are we about to cross to a new filesystem?
  		 */
 @@ -764,7 +767,6 @@ write_hierarchy(struct bsdtar *bsdtar, s
  		} else if (descend == 0) {
  			/* We're not descending, so no need to check. */
  		} else if (bsdtar->option_dont_traverse_mounts) {
 -			/* User has asked us not to cross mount points. */
  			descend = 0;
  		} else {
  			/* We're prepared to cross a mount point. */
 @@ -791,8 +793,15 @@ write_hierarchy(struct bsdtar *bsdtar, s
  		 * In -u mode, check that the file is newer than what's
  		 * already in the archive; in all modes, obey --newerXXX flags.
  		 */
 -		if (!new_enough(bsdtar, name, st))
 +		if (!new_enough(bsdtar, name, st)) {
 +			if (!descend)
 +				continue;
 +			if (bsdtar->option_interactive &&
 +			    !yes("add '%s'", name))
 +				continue;
 +			tree_descend(tree);
  			continue;
 +		}
  
  		archive_entry_free(entry);
  		entry = archive_entry_new();
 @@ -868,8 +877,7 @@ write_hierarchy(struct bsdtar *bsdtar, s
  		    !yes("add '%s'", name))
  			continue;
  
 -		/* Note: if user vetoes, we won't descend. */
 -		if (descend && !bsdtar->option_no_subdirs)
 +		if (descend)
  			tree_descend(tree);
  
  		/*
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
