SCCS-vsn: lib/libc/gen/fts.c 5.5
SCCS-vsn: lib/libc/gen/fts.3 5.4
.\" 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%
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
*/
#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>
}
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;
} 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);