From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 8 22:50:08 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1B5B81065672 for ; Sun, 8 Jul 2012 22:50:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E338E8FC08 for ; Sun, 8 Jul 2012 22:50:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q68Mo7EL062091 for ; Sun, 8 Jul 2012 22:50:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q68Mo7HS062090; Sun, 8 Jul 2012 22:50:07 GMT (envelope-from gnats) Resent-Date: Sun, 8 Jul 2012 22:50:07 GMT Resent-Message-Id: <201207082250.q68Mo7HS062090@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andrey Ignatov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 68DFD1065672 for ; Sun, 8 Jul 2012 22:41:51 +0000 (UTC) (envelope-from rdna@rdna.ru) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id DC8128FC0A for ; Sun, 8 Jul 2012 22:41:50 +0000 (UTC) Received: by lbon10 with SMTP id n10so19039822lbo.13 for ; Sun, 08 Jul 2012 15:41:49 -0700 (PDT) Received: by 10.112.48.39 with SMTP id i7mr17575383lbn.31.1341787309677; Sun, 08 Jul 2012 15:41:49 -0700 (PDT) Received: from localhost (ip-46-73-208-248.bb.netbynet.ru. [46.73.208.248]) by mx.google.com with ESMTPS id j3sm16252116lbh.0.2012.07.08.15.41.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 Jul 2012 15:41:48 -0700 (PDT) Message-Id: <4ffa0cac.631d700a.648c.ffffb394@mx.google.com> Date: Sun, 08 Jul 2012 15:41:48 -0700 (PDT) From: Andrey Ignatov To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Valery Khromov Subject: bin/169723: [patch] find(1) exits with non-zero return code if any file in a directory is deleted while find(1) is traversing the directory X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Andrey Ignatov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 22:50:08 -0000 >Number: 169723 >Category: bin >Synopsis: [patch] find(1) exits with non-zero return code if any file in a directory is deleted while find(1) is traversing the directory >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: Sun Jul 08 22:50:06 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Andrey Ignatov >Release: FreeBSD 10.0-CURRENT amd64 >Organization: Yandex >Environment: System: FreeBSD rdna-s761.yandex.ru 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r228743M: Sat Dec 31 15:15:00 MSK 2011 root@rdna.yandex.ru:/usr/obj/usr/src/sys/RDNA amd64 It seems that the problem appears in find(1) on many versions of FreeBSD (8-10 at least). >Description: find(1) exits with non-zero return code if any file in a directory is deleted while find(1) is traversing the directory, even though the file is completely out of find's expression. For example, we can run: % find /path/to/some/dir/ -type f -a ! -name '*some_mask*' Then while find is traversing the directory /path/to/some/dir/ we remove some files which is out of the expression: % rm /path/to/some/dir/*some_mask* (Note: I use "!" in the expression) After this find finishes with the result like this: find: /path/to/some/dir/some_mask: No such file or directory % echo $? 1 >How-To-Repeat: It's easy to reproduce the problem by using attached Makefile. Just run `make all'. >Fix: The patch is in attached freebsd-find-ENOENT-and-removed-files.patch file. Reported and patched by: Valery Khromov --- Makefile begins here --- D:=testdir FIND?=find all: prepare $(MAKE) -j16 mkfiles rmfiles find mkfiles: dd if=/dev/urandom | hexdump -e '"" 8/1 "%02x" "\n"' | while read i ; do touch "$(D)/$$i"; done rmfiles: while :; do rm -f $(D)/*; sleep 1; done find: while :; do $(FIND) $(D)/ -type f -name '*NAME*' || echo FAILED; done prepare: rm -rf $(D) mkdir -p $(D) --- Makefile ends here --- --- freebsd-find-ENOENT-and-removed-files.patch begins here --- Index: /usr/src/usr.bin/find/find.c =================================================================== --- /usr/src/usr.bin/find/find.c (revision 228743) +++ /usr/src/usr.bin/find/find.c (working copy) @@ -199,6 +199,8 @@ case FTS_DNR: case FTS_ERR: case FTS_NS: + if (entry->fts_errno == ENOENT) + continue; (void)fflush(stdout); warnx("%s: %s", entry->fts_path, strerror(entry->fts_errno)); --- freebsd-find-ENOENT-and-removed-files.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: