Deleted Added
full compact
fts-compat.c (129161) fts-compat.c (129184)
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
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 0
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 */
37#if defined(LIBC_SCCS) && !defined(lint)
38static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
39#endif /* LIBC_SCCS and not lint */
40#endif
41
39#include <sys/cdefs.h>
42#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/lib/libc/gen/fts-compat.c 129161 2004-05-12 21:38:39Z peadar $");
43__FBSDID("$FreeBSD: head/lib/libc/gen/fts-compat.c 129184 2004-05-13 15:59:38Z bde $");
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
44
45#include "namespace.h"
46#include <sys/param.h>
47#include <sys/mount.h>
48#include <sys/stat.h>
49
50#include <dirent.h>
51#include <errno.h>

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

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

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

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

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

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

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

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

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

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

--- 307 unchanged lines hidden ---