Coda Distributed File System
coda_fts.h
Go to the documentation of this file.
1// clang-format off
2/*
3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 4. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)fts.h 8.3 (Berkeley) 8/14/94
31 */
32
33#ifndef CODA_FTS_H
34#define CODA_FTS_H 1
35
36#ifdef HAVE_CONFIG_H
37#include <config.h>
38#endif
39
40#ifdef HAVE_FTS_H
41#include <fts.h>
42#else
43
44#include <sys/types.h>
45
46/* The fts interface is incompatible with the LFS interface which
47 transparently uses the 64-bit file access functions. */
48#ifdef __USE_FILE_OFFSET64
49# error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
50#endif
51
52
53typedef struct {
54 struct _ftsent *fts_cur; /* current node */
55 struct _ftsent *fts_child; /* linked list of children */
56 struct _ftsent **fts_array; /* sort array */
57 dev_t fts_dev; /* starting device # */
58 char *fts_path; /* path for this descent */
59 int fts_rfd; /* fd for root */
60 int fts_pathlen; /* sizeof(path) */
61 int fts_nitems; /* elements in the sort array */
62 int (*fts_compar) (const void *, const void *); /* compare fn */
63
64#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
65#define FTS_LOGICAL 0x0002 /* logical walk */
66#define FTS_NOCHDIR 0x0004 /* don't change directories */
67#define FTS_NOSTAT 0x0008 /* don't get stat info */
68#define FTS_PHYSICAL 0x0010 /* physical walk */
69#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
70#define FTS_XDEV 0x0040 /* don't cross devices */
71#define FTS_WHITEOUT 0x0080 /* return whiteout information */
72#define FTS_OPTIONMASK 0x00ff /* valid user option mask */
73
74#define FTS_NAMEONLY 0x0100 /* (private) child names only */
75#define FTS_STOP 0x0200 /* (private) unrecoverable error */
76 int fts_options; /* fts_open options, global flags */
77} FTS;
78
79typedef struct _ftsent {
80 struct _ftsent *fts_cycle; /* cycle node */
81 struct _ftsent *fts_parent; /* parent directory */
82 struct _ftsent *fts_link; /* next file in directory */
83 long fts_number; /* local numeric value */
84 void *fts_pointer; /* local address value */
85 char *fts_accpath; /* access path */
86 char *fts_path; /* root path */
87 int fts_errno; /* errno for this node */
88 int fts_symfd; /* fd for symlink */
89 u_short fts_pathlen; /* strlen(fts_path) */
90 u_short fts_namelen; /* strlen(fts_name) */
91
92 ino_t fts_ino; /* inode */
93 dev_t fts_dev; /* device */
94 nlink_t fts_nlink; /* link count */
95
96#define FTS_ROOTPARENTLEVEL -1
97#define FTS_ROOTLEVEL 0
98 short fts_level; /* depth (-1 to N) */
99
100#define FTS_D 1 /* preorder directory */
101#define FTS_DC 2 /* directory that causes cycles */
102#define FTS_DEFAULT 3 /* none of the above */
103#define FTS_DNR 4 /* unreadable directory */
104#define FTS_DOT 5 /* dot or dot-dot */
105#define FTS_DP 6 /* postorder directory */
106#define FTS_ERR 7 /* error; errno is set */
107#define FTS_F 8 /* regular file */
108#define FTS_INIT 9 /* initialized only */
109#define FTS_NS 10 /* stat(2) failed */
110#define FTS_NSOK 11 /* no stat(2) requested */
111#define FTS_SL 12 /* symbolic link */
112#define FTS_SLNONE 13 /* symbolic link without target */
113#define FTS_W 14 /* whiteout object */
114 u_short fts_info; /* user flags for FTSENT structure */
115
116#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
117#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
118 u_short fts_flags; /* private flags for FTSENT structure */
119
120#define FTS_AGAIN 1 /* read node again */
121#define FTS_FOLLOW 2 /* follow symbolic link */
122#define FTS_NOINSTR 3 /* no instructions */
123#define FTS_SKIP 4 /* discard node */
124 u_short fts_instr; /* fts_set() instructions */
125
126 struct stat *fts_statp; /* stat(2) information */
127 char fts_name[1]; /* file name */
129
130/* __BEGIN_DECLS */
131FTSENT *fts_children (FTS *, int);
132int fts_close (FTS *);
133FTS *fts_open (char * const *, int,
134 int (*)(const FTSENT **, const FTSENT **));
135FTSENT *fts_read (FTS *);
136int fts_set (FTS *, FTSENT *, int);
137/* __END_DECLS */
138
139#endif
140#endif /* CODA_FTS_H */
int fts_close(FTS *)
Definition: coda_fts.c:235
int fts_set(FTS *, FTSENT *, int)
Definition: coda_fts.c:484
FTSENT * fts_children(FTS *, int)
Definition: coda_fts.c:499
FTSENT * fts_read(FTS *)
Definition: coda_fts.c:290
struct _ftsent FTSENT
FTS * fts_open(char *const *, int, int(*)(const FTSENT **, const FTSENT **))
Definition: coda_fts.h:53
struct _ftsent * fts_cur
Definition: coda_fts.h:54
int fts_rfd
Definition: coda_fts.h:59
struct _ftsent ** fts_array
Definition: coda_fts.h:56
struct _ftsent * fts_child
Definition: coda_fts.h:55
dev_t fts_dev
Definition: coda_fts.h:57
int fts_options
Definition: coda_fts.h:76
char * fts_path
Definition: coda_fts.h:58
int fts_pathlen
Definition: coda_fts.h:60
int fts_nitems
Definition: coda_fts.h:61
Definition: coda_fts.h:79
char * fts_accpath
Definition: coda_fts.h:85
dev_t fts_dev
Definition: coda_fts.h:93
long fts_number
Definition: coda_fts.h:83
nlink_t fts_nlink
Definition: coda_fts.h:94
struct _ftsent * fts_link
Definition: coda_fts.h:82
short fts_level
Definition: coda_fts.h:98
struct _ftsent * fts_parent
Definition: coda_fts.h:81
u_short fts_namelen
Definition: coda_fts.h:90
ino_t fts_ino
Definition: coda_fts.h:92
u_short fts_info
Definition: coda_fts.h:114
char * fts_path
Definition: coda_fts.h:86
char fts_name[1]
Definition: coda_fts.h:127
u_short fts_instr
Definition: coda_fts.h:124
u_short fts_pathlen
Definition: coda_fts.h:89
struct _ftsent * fts_cycle
Definition: coda_fts.h:80
struct stat * fts_statp
Definition: coda_fts.h:126
int fts_errno
Definition: coda_fts.h:87
int fts_symfd
Definition: coda_fts.h:88
u_short fts_flags
Definition: coda_fts.h:118
void * fts_pointer
Definition: coda_fts.h:84