annotate lib/fts_.h @ 6035:a166800910b5

Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
author Jim Meyering <jim@meyering.net>
date Sun, 14 Aug 2005 14:45:33 +0000
parents c47674a83a78
children 43e3888c56c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
1 /* Traverse a file hierarchy.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
2
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
3 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
4
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
8 any later version.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
9
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
13 GNU General Public License for more details.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
14
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
16 along with this program; if not, write to the Free Software Foundation,
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
18
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
19 /*
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
20 * Copyright (c) 1989, 1993
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
21 * The Regents of the University of California. All rights reserved.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
22 *
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
23 * Redistribution and use in source and binary forms, with or without
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
24 * modification, are permitted provided that the following conditions
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
25 * are met:
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
26 * 1. Redistributions of source code must retain the above copyright
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
27 * notice, this list of conditions and the following disclaimer.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
28 * 2. Redistributions in binary form must reproduce the above copyright
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
29 * notice, this list of conditions and the following disclaimer in the
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
30 * documentation and/or other materials provided with the distribution.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
31 * 4. Neither the name of the University nor the names of its contributors
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
32 * may be used to endorse or promote products derived from this software
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
33 * without specific prior written permission.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
34 *
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
35 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
36 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
45 * SUCH DAMAGE.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
46 *
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
47 * @(#)fts.h 8.3 (Berkeley) 8/14/94
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
48 */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
49
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
50 #ifndef _FTS_H
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
51 # define _FTS_H 1
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
52
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
53 # ifdef _LIBC
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
54 # include <features.h>
5872
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
55 # define _LGPL_PACKAGE 1
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
56 # else
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
57 # undef __THROW
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
58 # define __THROW
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
59 # undef __BEGIN_DECLS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
60 # define __BEGIN_DECLS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
61 # undef __END_DECLS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
62 # define __END_DECLS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
63 # endif
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
64
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
65 # include <stddef.h>
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
66 # include <sys/types.h>
5867
67b499052f7f * fts.c: Include fts_.h first, to check interface.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5858
diff changeset
67 # include <sys/stat.h>
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
68
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
69 typedef struct {
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
70 struct _ftsent *fts_cur; /* current node */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
71 struct _ftsent *fts_child; /* linked list of children */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
72 struct _ftsent **fts_array; /* sort array */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
73 dev_t fts_dev; /* starting device # */
5907
c47674a83a78 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5872
diff changeset
74 char *fts_path; /* file name for this descent */
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
75 int fts_rfd; /* fd for root */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
76 size_t fts_pathlen; /* sizeof(path) */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
77 size_t fts_nitems; /* elements in the sort array */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
78 int (*fts_compar) (struct _ftsent const **, struct _ftsent const **);
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
79 /* compare fn */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
80
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
81 # define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
82 # define FTS_LOGICAL 0x0002 /* logical walk */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
83 # define FTS_NOCHDIR 0x0004 /* don't change directories */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
84 # define FTS_NOSTAT 0x0008 /* don't get stat info */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
85 # define FTS_PHYSICAL 0x0010 /* physical walk */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
86 # define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
87 # define FTS_XDEV 0x0040 /* don't cross devices */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
88 # define FTS_WHITEOUT 0x0080 /* return whiteout information */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
89
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
90 /* There are two ways to detect cycles.
6035
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
91 The lazy way (which works only with FTS_PHYSICAL),
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
92 with which one may process a directory that is a
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
93 part of the cycle several times before detecting the cycle.
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
94 The `tight' way, whereby fts uses more memory (proportional
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
95 to number of `active' directories, aka distance from root
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
96 of current tree to current directory -- see active_dir_ht)
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
97 to detect any cycle right away. For example, du must use
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
98 this option to avoid counting disk space in a cycle multiple
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
99 times, but chown -R need not.
6035
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
100 The default is to use the constant-memory lazy way, when possible
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
101 (see below).
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
102
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
103 However, with FTS_LOGICAL (when following symlinks, e.g., chown -L)
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
104 using lazy cycle detection is inadequate. For example, traversing
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
105 a directory containing a symbolic link to a peer directory, it is
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
106 possible to encounter the same directory twice even though there
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
107 is no cycle:
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
108 dir
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
109 ...
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
110 slink -> dir
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
111 So, when FTS_LOGICAL is selected, we have to use a different
a166800910b5 Mention that with FTS_LOGICAL, we use FTS_TIGHT_CYCLE_CHECK.
Jim Meyering <jim@meyering.net>
parents: 5907
diff changeset
112 mode of cycle detection: FTS_TIGHT_CYCLE_CHECK. */
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
113 # define FTS_TIGHT_CYCLE_CHECK 0x0100
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
114
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
115 # define FTS_OPTIONMASK 0x01ff /* valid user option mask */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
116
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
117 # define FTS_NAMEONLY 0x1000 /* (private) child names only */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
118 # define FTS_STOP 0x2000 /* (private) unrecoverable error */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
119 int fts_options; /* fts_open options, global flags */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
120
5872
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
121 # if !_LGPL_PACKAGE
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
122 union {
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
123 /* This data structure is used if FTS_TIGHT_CYCLE_CHECK is
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
124 specified. It records the directories between a starting
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
125 point and the current directory. I.e., a directory is
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
126 recorded here IFF we have visited it once, but we have not
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
127 yet completed processing of all its entries. Every time we
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
128 visit a new directory, we add that directory to this set.
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
129 When we finish with a directory (usually by visiting it a
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
130 second time), we remove it from this set. Each entry in
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
131 this data structure is a device/inode pair. This data
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
132 structure is used to detect directory cycles efficiently and
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
133 promptly even when the depth of a hierarchy is in the tens
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
134 of thousands. */
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
135 struct hash_table *ht;
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
136
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
137 /* This data structure uses lazy checking, as done by rm via
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
138 cycle-check.c. It's the default, but it's not appropriate
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
139 for programs like du. */
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
140 struct cycle_check_state *state;
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
141 } fts_cycle;
fab6701e5cb2 New fts module.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5867
diff changeset
142 # endif
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
143 } FTS;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
144
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
145 typedef struct _ftsent {
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
146 struct _ftsent *fts_cycle; /* cycle node */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
147 struct _ftsent *fts_parent; /* parent directory */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
148 struct _ftsent *fts_link; /* next file in directory */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
149 long fts_number; /* local numeric value */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
150 void *fts_pointer; /* local address value */
5907
c47674a83a78 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5872
diff changeset
151 char *fts_accpath; /* access file name */
c47674a83a78 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5872
diff changeset
152 char *fts_path; /* root name; == fts_fts->fts_path */
5858
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
153 int fts_errno; /* errno for this node */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
154 int fts_symfd; /* fd for symlink */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
155 size_t fts_pathlen; /* strlen(fts_path) */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
156
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
157 FTS *fts_fts; /* the file hierarchy itself */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
158
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
159 # define FTS_ROOTPARENTLEVEL (-1)
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
160 # define FTS_ROOTLEVEL 0
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
161 ptrdiff_t fts_level; /* depth (-1 to N) */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
162
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
163 size_t fts_namelen; /* strlen(fts_name) */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
164
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
165 # define FTS_D 1 /* preorder directory */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
166 # define FTS_DC 2 /* directory that causes cycles */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
167 # define FTS_DEFAULT 3 /* none of the above */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
168 # define FTS_DNR 4 /* unreadable directory */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
169 # define FTS_DOT 5 /* dot or dot-dot */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
170 # define FTS_DP 6 /* postorder directory */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
171 # define FTS_ERR 7 /* error; errno is set */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
172 # define FTS_F 8 /* regular file */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
173 # define FTS_INIT 9 /* initialized only */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
174 # define FTS_NS 10 /* stat(2) failed */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
175 # define FTS_NSOK 11 /* no stat(2) requested */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
176 # define FTS_SL 12 /* symbolic link */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
177 # define FTS_SLNONE 13 /* symbolic link without target */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
178 # define FTS_W 14 /* whiteout object */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
179 unsigned short int fts_info; /* user flags for FTSENT structure */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
180
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
181 # define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
182 # define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
183 unsigned short int fts_flags; /* private flags for FTSENT structure */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
184
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
185 # define FTS_AGAIN 1 /* read node again */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
186 # define FTS_FOLLOW 2 /* follow symbolic link */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
187 # define FTS_NOINSTR 3 /* no instructions */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
188 # define FTS_SKIP 4 /* discard node */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
189 unsigned short int fts_instr; /* fts_set() instructions */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
190
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
191 struct stat fts_statp[1]; /* stat(2) information */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
192 char fts_name[1]; /* file name */
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
193 } FTSENT;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
194
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
195 __BEGIN_DECLS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
196 FTSENT *fts_children (FTS *, int) __THROW;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
197 int fts_close (FTS *) __THROW;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
198 FTS *fts_open (char * const *, int,
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
199 int (*)(const FTSENT **, const FTSENT **)) __THROW;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
200 FTSENT *fts_read (FTS *) __THROW;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
201 int fts_set (FTS *, FTSENT *, int) __THROW;
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
202 __END_DECLS
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
203
942c4d17dd7d New files, from coreutils.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
204 #endif /* fts.h */