add FTS_XDEV; don't cross mount points
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 23 May 1990 09:57:50 +0000 (01:57 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 23 May 1990 09:57:50 +0000 (01:57 -0800)
SCCS-vsn: lib/libc/gen/fts.c 5.5
SCCS-vsn: lib/libc/gen/fts.3 5.4

usr/src/lib/libc/gen/fts.3
usr/src/lib/libc/gen/fts.c

index 4015b9f..95434ff 100644 (file)
@@ -13,7 +13,7 @@
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.\"    @(#)fts.3       5.3 (Berkeley) %G%
+.\"    @(#)fts.3       5.4 (Berkeley) %G%
 .\"
 .TH FTS 3 ""
 .UC 7
 .\"
 .TH FTS 3 ""
 .UC 7
@@ -142,6 +142,12 @@ This option causes the routine
 to return structures for the directory entries ``.'' and ``..''.
 By default they are ignored unless specified as an argument to
 .IR ftsopen .
 to return structures for the directory entries ``.'' and ``..''.
 By default they are ignored unless specified as an argument to
 .IR ftsopen .
+.TP
+FTS_XDEV
+This option keeps
+.I fts
+from descending into directories that have a different device number
+than the file the descent began from.
 .PP
 The argument
 .I compar
 .PP
 The argument
 .I compar
index f97b131..a5429c2 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fts.c      5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)fts.c      5.5 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -239,7 +239,8 @@ ftsread(sp)
        }
 
        if (p->fts_info == FTS_D)
        }
 
        if (p->fts_info == FTS_D)
-               if (instr == FTS_SKIP) {
+               if (instr == FTS_SKIP || sp->fts_options & FTS_XDEV &&
+                   p->fts_statb.st_dev != sp->sdev) {
                        if (sp->fts_child) {
                                fts_lfree(sp->fts_child);
                                sp->fts_child = NULL;
                        if (sp->fts_child) {
                                fts_lfree(sp->fts_child);
                                sp->fts_child = NULL;
@@ -300,6 +301,7 @@ ftsread(sp)
                        } else
                                cd = 1;
                        p->fts_info = fts_stat(p, 0);
                        } else
                                cd = 1;
                        p->fts_info = fts_stat(p, 0);
+                       sp->sdev = p->fts_statb.st_dev;
                } else {
                        (void)free((char *)sp->fts_cur);
                        cp = sp->fts_path + NAPPEND(p->fts_parent);
                } else {
                        (void)free((char *)sp->fts_cur);
                        cp = sp->fts_path + NAPPEND(p->fts_parent);