Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Nov 2010 22:15:20 +0800
From:      "Denise H. G." <darcsis@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/152673: [patch] find(1): correctly find empty dirs.
Message-ID:  <868w0c6wsn.fsf@pluton.xbsd.name>
Resent-Message-ID: <201011291420.oATEKCHg056800@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         152673
>Category:       bin
>Synopsis:       [patch] find(1): correctly find empty dirs.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 29 14:20:12 UTC 2010
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?868w0c6wsn.fsf>