From darcsis@gmail.com  Mon Nov 29 14:15:34 2010
Return-Path: <darcsis@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C59D0106564A
	for <freebsd-gnats-submit@freebsd.org>; Mon, 29 Nov 2010 14:15:34 +0000 (UTC)
	(envelope-from darcsis@gmail.com)
Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 838838FC16
	for <freebsd-gnats-submit@freebsd.org>; Mon, 29 Nov 2010 14:15:34 +0000 (UTC)
Received: by iwn39 with SMTP id 39so5697186iwn.13
        for <freebsd-gnats-submit@freebsd.org>; Mon, 29 Nov 2010 06:15:33 -0800 (PST)
Received: by 10.231.35.138 with SMTP id p10mr5686374ibd.104.1291040133403;
        Mon, 29 Nov 2010 06:15:33 -0800 (PST)
Received: from smtp.xbsd.name ([123.117.56.42])
        by mx.google.com with ESMTPS id 8sm5963682iba.16.2010.11.29.06.15.30
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 29 Nov 2010 06:15:32 -0800 (PST)
Received: from pluton.xbsd.name (pluton.xbsd.name [172.16.1.10])
	by smtp.xbsd.name (OpenSMTPD) with ESMTP id 8mpS5NzI
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128)
	for <freebsd-gnats-submit@freebsd.org>; Mon, 29 Nov 2010 22:15:23 +0800 (CST)
Message-Id: <868w0c6wsn.fsf@pluton.xbsd.name>
Date: Mon, 29 Nov 2010 22:15:20 +0800
From: Denise H. G. <darcsis@gmail.com>
Reply-To: Denise H. G. <darcsis@gmail.com>
To: freebsd-gnats-submit@freebsd.org
Cc:
Subject: [patch] find(1): correctly find empty dirs.
X-Send-Pr-Version: MiSendPr 0.3
X-GNATS-Notify:

>Number:         152673
>Category:       bin
>Synopsis:       [patch] find(1): correctly find empty dirs.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kevlo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 29 14:20:12 UTC 2010
>Closed-Date:    Tue Dec 28 02:26:51 UTC 2010
>Last-Modified:  Tue Dec 28 02:26:51 UTC 2010
>Originator:     Denise H. G.
>Release:        FreeBSD 8.2-PRERELEASE amd64
>Organization:
XBSD Networks
>Environment:
System: FreeBSD pluton.xbsd.name 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Mon Nov 29 08:41:06 CST 2010 root@pluton.xbsd.name:/opt/obj/sysbld/usr/src/sys/pluton-amd64 amd64

>Description:

	While searching for empty directories, find(1) quits if it encounters the first dir it can't descend into. However, it is supposed to print out an warning message and continue with the rest of the file hierachy.

>How-To-Repeat:

	As a non-privileged user, execute:

        find /var -type d -empty

>Fix:

	
--- function.c.diff begins here ---
--- usr.bin/find/function.c.orig	2010-11-29 21:44:30.451542259 +0800
+++ usr.bin/find/function.c	2010-11-29 21:49:24.670933099 +0800
@@ -559,8 +559,10 @@
 
 		empty = 1;
 		dir = opendir(entry->fts_accpath);
-		if (dir == NULL)
-			err(1, "%s", entry->fts_accpath);
+		if (dir == NULL) {
+			warn("%s", entry->fts_accpath);
+			return 0;
+		}
 		for (dp = readdir(dir); dp; dp = readdir(dir))
 			if (dp->d_name[0] != '.' ||
 			    (dp->d_name[1] != '\0' &&
--- function.c.diff ends here ---
>Release-Note:
>Audit-Trail:

From: "Denise H. G." <darcsis@gmail.com>
To: bug-followup@FreeBSD.org, darcsis@gmail.com
Cc:  
Subject: Re: bin/152673: [patch] find(1): correctly find empty dirs.
Date: Wed, 1 Dec 2010 14:44:47 +0800

 --0016e64e9c0e28d4d9049653a403
 Content-Type: multipart/alternative; boundary=0016e64e9c0e28d4d0049653a401
 
 --0016e64e9c0e28d4d0049653a401
 Content-Type: text/plain; charset=ISO-8859-1
 
 remove warn() which duplicates the output of the warning message.
 
 --0016e64e9c0e28d4d0049653a401
 Content-Type: text/html; charset=ISO-8859-1
 
 remove warn() which duplicates the output of the warning message.<br><br>
 
 --0016e64e9c0e28d4d0049653a401--
 --0016e64e9c0e28d4d9049653a403
 Content-Type: application/octet-stream; name="functions.c.diff"
 Content-Disposition: attachment; filename="functions.c.diff"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_gh5upyr80
 
 LS0tIHVzci5iaW4vZmluZC9mdW5jdGlvbi5jLm9yaWcJMjAxMC0xMi0wMSAxNDozNDoyMy4wMDAw
 MDAwMDAgKzA4MDAKKysrIHVzci5iaW4vZmluZC9mdW5jdGlvbi5jCTIwMTAtMTItMDEgMTQ6Mjg6
 NTIuMDAwMDAwMDAwICswODAwCkBAIC01NjAsNyArNTYwLDcgQEAKIAkJZW1wdHkgPSAxOwogCQlk
 aXIgPSBvcGVuZGlyKGVudHJ5LT5mdHNfYWNjcGF0aCk7CiAJCWlmIChkaXIgPT0gTlVMTCkKLSAg
 ICAgICAgICAgICAgICAgICAgICAgIGVycigxLCAiJXMiLCBlbnRyeS0+ZnRzX2FjY3BhdGgpOwor
 ICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAJCWZvciAoZHAgPSByZWFkZGlyKGRp
 cik7IGRwOyBkcCA9IHJlYWRkaXIoZGlyKSkKIAkJCWlmIChkcC0+ZF9uYW1lWzBdICE9ICcuJyB8
 fAogCQkJICAgIChkcC0+ZF9uYW1lWzFdICE9ICdcMCcgJiYK
 --0016e64e9c0e28d4d9049653a403--
State-Changed-From-To: open->patched 
State-Changed-By: arundel 
State-Changed-When: Thu Dec 2 19:16:02 UTC 2010 
State-Changed-Why:  
Fixed in HEAD (r216106). 


Responsible-Changed-From-To: freebsd-bugs->kevlo 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Thu Dec 2 19:16:02 UTC 2010 
Responsible-Changed-Why:  
Over to committer as MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152673 
State-Changed-From-To: patched->closed 
State-Changed-By: kevlo 
State-Changed-When: Tue Dec 28 02:26:07 UTC 2010 
State-Changed-Why:  
Fixed in stable/8 

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