Deleted Added
sdiff udiff text old ( 129161 ) new ( 129184 )
full compact
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
38#endif /* LIBC_SCCS and not lint */
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/lib/libc/gen/fts-compat.c 129161 2004-05-12 21:38:39Z peadar $");
41
42#include "namespace.h"
43#include <sys/param.h>
44#include <sys/mount.h>
45#include <sys/stat.h>
46
47#include <dirent.h>
48#include <errno.h>

--- 72 unchanged lines hidden (view full) ---

121 int len;
122
123 /* Options check. */
124 if (options & ~FTS_OPTIONMASK) {
125 errno = EINVAL;
126 return (NULL);
127 }
128
129 /* Allocate/initialize the stream */
130 if ((priv = malloc(sizeof(*priv))) == NULL)
131 return (NULL);
132 memset(priv, 0, sizeof(*priv));
133 sp = &priv->ftsp_fts;
134 sp->fts_compar = compar;
135 sp->fts_options = options;
136
137 /* Shush, GCC. */

--- 241 unchanged lines hidden (view full) ---

379 *
380 * If haven't read do so. If the read fails, fts_build sets
381 * FTS_STOP or the fts_info field of the node.
382 */
383 if (sp->fts_child != NULL) {
384 if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) {
385 p->fts_errno = errno;
386 p->fts_flags |= FTS_DONTCHDIR;
387 for (p = sp->fts_child; p != NULL;
388 p = p->fts_link)
389 p->fts_accpath =
390 p->fts_parent->fts_accpath;
391 }
392 } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) {
393 if (ISSET(FTS_STOP))
394 return (NULL);
395 return (p);

--- 79 unchanged lines hidden (view full) ---

475 saved_errno = errno;
476 (void)_close(p->fts_symfd);
477 errno = saved_errno;
478 SET(FTS_STOP);
479 return (NULL);
480 }
481 (void)_close(p->fts_symfd);
482 } else if (!(p->fts_flags & FTS_DONTCHDIR) &&
483 fts_safe_changedir(sp, p->fts_parent, -1, "..")) {
484 SET(FTS_STOP);
485 return (NULL);
486 }
487 p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
488 return (sp->fts_cur = p);
489}
490
491/*

--- 148 unchanged lines hidden (view full) ---

640 cur = sp->fts_cur;
641
642 /*
643 * Open the directory for reading. If this fails, we're done.
644 * If being called from fts_read, set the fts_info field.
645 */
646#ifdef FTS_WHITEOUT
647 if (ISSET(FTS_WHITEOUT))
648 oflag = DTF_NODUP|DTF_REWIND;
649 else
650 oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND;
651#else
652#define __opendir2(path, flag) opendir(path)
653#endif
654 if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) {
655 if (type == BREAD) {
656 cur->fts_info = FTS_DNR;
657 cur->fts_errno = errno;
658 }

--- 240 unchanged lines hidden (view full) ---

899 ino_t ino;
900 struct stat *sbp, sb;
901 int saved_errno;
902
903 /* If user needs stat info, stat buffer already allocated. */
904 sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
905
906#ifdef FTS_WHITEOUT
907 /* check for whiteout */
908 if (p->fts_flags & FTS_ISW) {
909 if (sbp != &sb) {
910 memset(sbp, '\0', sizeof (*sbp));
911 sbp->st_mode = S_IFWHT;
912 }
913 return (FTS_W);
914 }
915#endif
916
917 /*
918 * If doing a logical walk, or application requested FTS_FOLLOW, do

--- 307 unchanged lines hidden ---