Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/gen Readd my change from fts.c rev 1.10, which was ...



details:   https://anonhg.NetBSD.org/src/rev/86a06fa762ee
branches:  trunk
changeset: 475859:86a06fa762ee
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Fri Aug 27 21:10:46 1999 +0000

description:
Readd my change from fts.c rev 1.10, which was incorrectly removed in rev 1.19
(HI CHRISTOS!):
Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.

diffstat:

 lib/libc/gen/__fts13.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r c925b2623769 -r 86a06fa762ee lib/libc/gen/__fts13.c
--- a/lib/libc/gen/__fts13.c    Fri Aug 27 20:05:08 1999 +0000
+++ b/lib/libc/gen/__fts13.c    Fri Aug 27 21:10:46 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __fts13.c,v 1.24 1999/08/27 20:02:14 mycroft Exp $     */
+/*     $NetBSD: __fts13.c,v 1.25 1999/08/27 21:10:46 mycroft Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)fts.c      8.6 (Berkeley) 8/14/94";
 #else
-__RCSID("$NetBSD: __fts13.c,v 1.24 1999/08/27 20:02:14 mycroft Exp $");
+__RCSID("$NetBSD: __fts13.c,v 1.25 1999/08/27 21:10:46 mycroft Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -602,7 +602,7 @@
        size_t nitems;
        FTSENT *cur, *tail;
        DIR *dirp;
-       int adjust, cderrno, descend, len, level, nlinks, saved_errno;
+       int adjust, cderrno, descend, len, level, nlinks, saved_errno, nostat;
        size_t maxlen;
 #ifdef FTS_WHITEOUT
        int oflag;
@@ -637,12 +637,16 @@
         * directory if we're cheating on stat calls, 0 if we're not doing
         * any stat calls at all, -1 if we're doing stats on everything.
         */
-       if (type == BNAMES)
+       if (type == BNAMES) {
                nlinks = 0;
-       else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL))
+               nostat = 1;
+       } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) {
                nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2);
-       else
+               nostat = 1;
+       } else {
                nlinks = -1;
+               nostat = 0;
+       }
 
 #ifdef notdef
        (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink);
@@ -753,7 +757,7 @@
                        p->fts_accpath = cur->fts_accpath;
                } else if (nlinks == 0
 #ifdef DT_DIR
-                   || (nlinks > 0 && 
+                   || (nostat && 
                    dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)
 #endif
                    ) {



Home | Main Index | Thread Index | Old Index