fts.h revision 1.6 1 /* $NetBSD: fts.h,v 1.6 1997/10/21 00:55:10 fvdl Exp $ */
2
3 /*
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)fts.h 8.3 (Berkeley) 8/14/94
36 */
37
38 #ifndef _FTS_H_
39 #define _FTS_H_
40
41 /*
42 * fts_options flags
43 */
44 #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */
45 #define FTS_LOGICAL 0x002 /* logical walk */
46 #define FTS_NOCHDIR 0x004 /* don't change directories */
47 #define FTS_NOSTAT 0x008 /* don't get stat info */
48 #define FTS_PHYSICAL 0x010 /* physical walk */
49 #define FTS_SEEDOT 0x020 /* return dot and dot-dot */
50 #define FTS_XDEV 0x040 /* don't cross devices */
51 #define FTS_WHITEOUT 0x080 /* return whiteout information */
52 #define FTS_OPTIONMASK 0x0ff /* valid user option mask */
53
54 #define FTS_NAMEONLY 0x100 /* (private) child names only */
55 #define FTS_STOP 0x200 /* (private) unrecoverable error */
56
57 typedef struct {
58 struct _ftsent12 *fts_cur; /* current node */
59 struct _ftsent12 *fts_child; /* linked list of children */
60 struct _ftsent12 **fts_array; /* sort array */
61 dev_t fts_dev; /* starting device # */
62 char *fts_path; /* path for this descent */
63 int fts_rfd; /* fd for root */
64 int fts_pathlen; /* sizeof(path) */
65 int fts_nitems; /* elements in the sort array */
66 int (*fts_compar)(); /* compare function */
67
68 int fts_options; /* fts_open options, global flags */
69 } FTS12;
70
71 typedef struct {
72 struct _ftsent *fts_cur; /* current node */
73 struct _ftsent *fts_child; /* linked list of children */
74 struct _ftsent **fts_array; /* sort array */
75 dev_t fts_dev; /* starting device # */
76 char *fts_path; /* path for this descent */
77 int fts_rfd; /* fd for root */
78 int fts_pathlen; /* sizeof(path) */
79 int fts_nitems; /* elements in the sort array */
80 int (*fts_compar)(); /* compare function */
81
82 int fts_options; /* fts_open options, global flags */
83 } FTS;
84
85 /*
86 * fts_level defines.
87 */
88 #define FTS_ROOTPARENTLEVEL -1
89 #define FTS_ROOTLEVEL 0
90
91 /*
92 * fts_info defines
93 */
94 #define FTS_D 1 /* preorder directory */
95 #define FTS_DC 2 /* directory that causes cycles */
96 #define FTS_DEFAULT 3 /* none of the above */
97 #define FTS_DNR 4 /* unreadable directory */
98 #define FTS_DOT 5 /* dot or dot-dot */
99 #define FTS_DP 6 /* postorder directory */
100 #define FTS_ERR 7 /* error; errno is set */
101 #define FTS_F 8 /* regular file */
102 #define FTS_INIT 9 /* initialized only */
103 #define FTS_NS 10 /* stat(2) failed */
104 #define FTS_NSOK 11 /* no stat(2) requested */
105 #define FTS_SL 12 /* symbolic link */
106 #define FTS_SLNONE 13 /* symbolic link without target */
107 #define FTS_W 14 /* whiteout object */
108
109 /*
110 * fts_flags defines
111 */
112 #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
113 #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
114 #define FTS_ISW 0x04 /* this is a whiteout object */
115
116 /*
117 * fts_set instructions
118 */
119 #define FTS_AGAIN 1 /* read node again */
120 #define FTS_FOLLOW 2 /* follow symbolic link */
121 #define FTS_NOINSTR 3 /* no instructions */
122 #define FTS_SKIP 4 /* discard node */
123
124 typedef struct _ftsent {
125 struct _ftsent *fts_cycle; /* cycle node */
126 struct _ftsent *fts_parent; /* parent directory */
127 struct _ftsent *fts_link; /* next file in directory */
128 long fts_number; /* local numeric value */
129 void *fts_pointer; /* local address value */
130 char *fts_accpath; /* access path */
131 char *fts_path; /* root path */
132 int fts_errno; /* errno for this node */
133 int fts_symfd; /* fd for symlink */
134 u_short fts_pathlen; /* strlen(fts_path) */
135 u_short fts_namelen; /* strlen(fts_name) */
136
137 ino_t fts_ino; /* inode */
138 dev_t fts_dev; /* device */
139 nlink_t fts_nlink; /* link count */
140
141 short fts_level; /* depth (-1 to N) */
142
143 u_short fts_info; /* user flags for FTSENT structure */
144
145 u_short fts_flags; /* private flags for FTSENT structure */
146
147 u_short fts_instr; /* fts_set() instructions */
148
149 struct stat *fts_statp; /* stat(2) information */
150 char fts_name[1]; /* file name */
151 } FTSENT;
152
153 typedef struct _ftsent12 {
154 struct _ftsent12 *fts_cycle; /* cycle node */
155 struct _ftsent12 *fts_parent; /* parent directory */
156 struct _ftsent12 *fts_link; /* next file in directory */
157 long fts_number; /* local numeric value */
158 void *fts_pointer; /* local address value */
159 char *fts_accpath; /* access path */
160 char *fts_path; /* root path */
161 int fts_errno; /* errno for this node */
162 int fts_symfd; /* fd for symlink */
163 u_short fts_pathlen; /* strlen(fts_path) */
164 u_short fts_namelen; /* strlen(fts_name) */
165
166 ino_t fts_ino; /* inode */
167 dev_t fts_dev; /* device */
168 u_int16_t fts_nlink; /* link count */
169
170 short fts_level; /* depth (-1 to N) */
171
172 u_short fts_info; /* user flags for FTSENT structure */
173
174 u_short fts_flags; /* private flags for FTSENT structure */
175
176 u_short fts_instr; /* fts_set() instructions */
177
178 struct stat12 *fts_statp; /* stat(2) information */
179 char fts_name[1]; /* file name */
180 } FTSENT12;
181
182 #include <sys/cdefs.h>
183
184 __BEGIN_DECLS
185 FTSENT12 *fts_children __P((FTS12 *, int));
186 int fts_close __P((FTS12 *));
187 FTS12 *fts_open __P((char * const *, int,
188 int (*)(const FTSENT12 **, const FTSENT12 **)));
189 FTSENT12 *fts_read __P((FTS12 *));
190 int fts_set __P((FTS12 *, FTSENT12 *, int));
191
192 FTSENT *__fts_children13 __P((FTS *, int));
193 int __fts_close13 __P((FTS *));
194 FTS *__fts_open13 __P((char * const *, int,
195 int (*)(const FTSENT **, const FTSENT **)));
196 FTSENT *__fts_read13 __P((FTS *));
197 int __fts_set13 __P((FTS *, FTSENT *, int));
198 __END_DECLS
199
200 #define fts_children(f,i) __fts_children13(f,i)
201 #define fts_close(f) __fts_close13(f)
202 #define fts_open(p,i,f) __fts_open13(p,i,f)
203 #define fts_read(f) __fts_read13(f)
204 #define fts_set(f,g,i) __fts_set13(f,g,i)
205
206 #endif /* !_FTS_H_ */
207