Deleted Added
sdiff udiff text old ( 276219 ) new ( 279527 )
full compact
1#include "config.h"
2
3#if HAVE_FTS
4
5int dummy;
6
7#else
8
9/* $Id: compat_fts.c,v 1.6 2014/12/11 18:20:07 schwarze Exp $ */
10/* $OpenBSD: fts.c,v 1.49 2014/11/23 00:14:22 guenther Exp $ */
11
12/*-
13 * Copyright (c) 1990, 1993, 1994
14 * The Regents of the University of California. All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:

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

33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 */
40
41#include <sys/param.h>
42#include <sys/stat.h>
43#include <sys/types.h>
44
45#include <dirent.h>
46#include <errno.h>
47#include <fcntl.h>
48#include <limits.h>
49#include <stdlib.h>
50#include <string.h>
51#include <unistd.h>
52#include "compat_fts.h"
53
54static FTSENT *fts_alloc(FTS *, const char *, size_t);
55static FTSENT *fts_build(FTS *);
56static void fts_lfree(FTSENT *);
57static void fts_load(FTS *, FTSENT *);
58static size_t fts_maxarglen(char * const *);
59static void fts_padjust(FTS *, FTSENT *);
60static int fts_palloc(FTS *, size_t);
61static unsigned short fts_stat(FTS *, FTSENT *);
62static int fts_safe_changedir(FTS *, FTSENT *, int, const char *);
63
64#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
65#define MAX(a,b) (((a)>(b))?(a):(b))
66#ifndef O_DIRECTORY
67#define O_DIRECTORY 0
68#endif
69
70#define CLR(opt) (sp->fts_options &= ~(opt))
71#define ISSET(opt) (sp->fts_options & (opt))
72#define SET(opt) (sp->fts_options |= (opt))
73
74#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd))
75
76FTS *

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

92 if ((sp = calloc(1, sizeof(FTS))) == NULL)
93 return (NULL);
94 sp->fts_options = options;
95
96 /*
97 * Start out with 1K of path space, and enough, in any case,
98 * to hold the user's paths.
99 */
100 if (fts_palloc(sp, MAX(fts_maxarglen(argv), PATH_MAX)))
101 goto mem1;
102
103 /* Allocate/initialize root's parent. */
104 if ((parent = fts_alloc(sp, "", 0)) == NULL)
105 goto mem2;
106 parent->fts_level = FTS_ROOTPARENTLEVEL;
107
108 /* Allocate/initialize root(s). */

--- 697 unchanged lines hidden ---