xref: /csrg-svn/lib/libc/gen/fts.3 (revision 52075)
148352Scael.\" Copyright (c) 1989, 1991 The Regents of the University of California.
239801Sbostic.\" All rights reserved.
339801Sbostic.\"
443571Strent.\" %sccs.include.redist.man%
539801Sbostic.\"
6*52075Sbostic.\"     @(#)fts.3	5.14 (Berkeley) 12/30/91
739801Sbostic.\"
848352Scael.Dd
948352Scael.Dt FTS 3
1048352Scael.Os
1148352Scael.Sh NAME
1248352Scael.Nm fts
1348352Scael.Nd traverse a file hierarchy
1448352Scael.Sh SYNOPSIS
1548352Scael.Fd #include <sys/types.h>
1648352Scael.Fd #include <sys/stat.h>
1748352Scael.Fd #include <fts.h>
1848352Scael.Ft FTS *
1948352Scael.Fn fts_open "char * const *path_argv" "int options" "int *compar(const FTSENT *, const FTSENT *)"
2048352Scael.Ft FTSENT *
2148352Scael.Fn fts_read "FTS *ftsp"
2248352Scael.Ft FTSENT *
2348352Scael.Fn fts_children "FTS *ftsp"
2448352Scael.Ft int
2548352Scael.Fn fts_set "FTS ftsp" "FTSENT *f" "int options"
2648352Scael.Ft int
2748352Scael.Fn fts_close "FTS *ftsp"
2848352Scael.Sh DESCRIPTION
2939801SbosticThe
3048352Scael.Nm fts
3148352Scaelfunctions are provided for traversing
3248352Scael.Tn UNIX
3348352Scaelfile hierarchies.
3448352Scael.Pp
3547194SbosticThe simple overview is that the
3648352Scael.Fn fts_open
3747194Sbosticfunction returns a ``handle'' on a file hierarchy, which is supplied to
3847194Sbosticthe other
3948352Scael.Nm fts
4045617Sbosticfunctions to determine which hierarchy they operate on.
4145617SbosticThe function
4248352Scael.Fn fts_read
4345617Sbosticreturns a pointer to a structure describing one of the files in the file
4445617Sbostichierarchy.
4545617SbosticThe function
4648352Scael.Fn fts_children
4745617Sbosticreturns a pointer to a linked list of structures, each of which describes
4845617Sbosticone of the files contained in a directory in the hierarchy.
4945617SbosticIn general, directories are visited two distinguishable times; in pre-order
5045617Sbostic(before any of their descendants are visited) and in post-order (after all
5145617Sbosticof their descendants have been visited).
5245617SbosticFiles are visited once.
5345617SbosticIt is possible to walk the hierarchy ``logically'' (ignoring symbolic links)
5445617Sbosticor physically (visiting symbolic links), order the walk of the hierarchy or
5545617Sbosticprune and/or re-visit portions of the hierarchy.
5648352Scael.Pp
5748352ScaelTwo structures are defined (and typedef'd) in the include file
5848352Scael.Aq Pa fts.h .
5948352ScaelThe first is
6048352Scael.Fa FTS ,
6148352Scaelthe structure that represents the file hierarchy stream.
6248352ScaelThe second is
6348352Scael.Fa FTSENT ,
6448352Scaelthe structure that represents a file in the file
6545617Sbostichierarchy.
6648352ScaelNormally, an
6748352Scael.Fa FTSENT
6848352Scaelstructure is returned for every file in the file
6945617Sbostichierarchy.
7048352ScaelIn this manual page, ``file'' and
7148352Scael.Dq Fa FTSENT No structure
7248352Scaelare generally
7345617Sbosticinterchangeable.
7448352ScaelThe
7548352Scael.Fa FTSENT
7648352Scaelstructure contains at least the following fields, which are
7745617Sbosticdescribed in greater detail below:
7850725Scael.Bd -literal
7945617Sbostictypedef struct _ftsent {
8048352Scael	u_short fts_info;		/* flags for FTSENT structure */
8148352Scael	char *fts_accpath;		/* access path */
8245617Sbostic	char *fts_path;			/* root path */
8348352Scael	short fts_pathlen;		/* strlen(fts_path) */
8442273Sbostic	char *fts_name;			/* file name */
8548352Scael	short fts_namelen;		/* strlen(fts_name) */
8648352Scael	short fts_level;		/* depth (\-1 to N) */
8748352Scael	long fts_number;		/* local numeric value */
8845617Sbostic	void *fts_pointer;		/* local address value */
8948352Scael	struct ftsent *fts_parent;	/* parent directory */
90*52075Sbostic	struct ftsent *fts_link;	/* next file structure */
91*52075Sbostic	struct ftsent *fts_cycle;	/* cycle structure */
9248352Scael	struct stat fts_statb;		/* stat(2) information */
9339801Sbostic} FTSENT;
9448352Scael.Ed
9548352Scael.Pp
9645617SbosticThese fields are defined as follows:
9748352Scael.Bl -tag -width "fts_namelen"
9848352Scael.It Fa fts_info
9948352ScaelOne of the following flags describing the returned
10048352Scael.Fa FTSENT
10148352Scaelstructure and
10245617Sbosticthe file it represents.
10348352ScaelWith the exception of directories without errors
10448352Scael.Pq Dv FTS_D ,
10548352Scaelall of these
10645617Sbosticentries are terminal, that is, they will not be revisited, nor will any
10745617Sbosticof their descendants be visited.
10848352Scael.Bl  -tag -width FTS_DEFAULT
10948352Scael.It Dv FTS_D
11039801SbosticA directory being visited in pre-order.
11148352Scael.It Dv FTS_DC
11245617SbosticA directory that causes a cycle in the tree.
11345617Sbostic(The
114*52075Sbostic.Fa fts_cycle
11548352Scaelfield of the
11648352Scael.Fa FTSENT
11748352Scaelstructure will be filled in as well.)
11848352Scael.It Dv FTS_DEFAULT
11948352ScaelAny
12048352Scael.Fa FTSENT
12148352Scaelstructure that represents a file type not explicitly described
12245617Sbosticby one of the other
12348352Scael.Fa fts_info
12445617Sbosticvalues.
12548352Scael.It Dv FTS_DNR
12645617SbosticA directory which cannot be read.
12747194SbosticAn error return; the external variable
12848352Scael.Va errno
12947194Sbosticwill be set to indicate the error.
13048352Scael.It Dv FTS_DP
13145617SbosticA directory being visited in post-order.
13248352ScaelThe contents of the
13348352Scael.Fa FTSENT
13448352Scaelstructure will be unchanged from when
13545617Sbosticit was returned in pre-order, i.e. with the
13648352Scael.Fa fts_info
13748352Scaelfield set to
13848352Scael.Dv FTS_D .
13948352Scael.It Dv FTS_ERR
14045617SbosticAn error return; the external variable
14148352Scael.Va errno
14245617Sbosticwill be set to indicate the error.
14348352Scael.It Dv FTS_F
14439801SbosticA regular file.
14548352Scael.It Dv FTS_NS
14645617SbosticA file for which no
14748352Scael.Xr stat 2
14847194Sbosticinformation was available.
14947194SbosticThe contents of the
15048352Scael.Fa fts_statb
15139801Sbosticfield are undefined.
15247194SbosticAn error return; the external variable
15348352Scael.Va errno
15447194Sbosticwill be set to indicate the error.
15548352Scael.It Dv FTS_NSOK
15647194SbosticA file for which no
15748352Scael.Xr stat 2
15847194Sbosticinformation was requested.
15947194SbosticThe contents of the
16048352Scael.Fa fts_statb
16147194Sbosticfield are undefined.
16248352Scael.It Dv FTS_SL
16339801SbosticA symbolic link.
16448352Scael.It Dv FTS_SLNONE
16539801SbosticA symbolic link with a non-existent target.
16647194SbosticThe contents of the
16748352Scael.Fa fts_statb
16847194Sbosticfield contain the file characteristic information for the symbolic link
16947194Sbosticitself.
17048352Scael.El
17148352Scael.It Fa fts_accpath
17247194SbosticA path for accessing the file from the current directory.
17348352Scael.It Fa fts_path
17445617SbosticThe path for the file relative to the root of the traversal.
17545617SbosticThis path contains the path specified to
17648352Scael.Fn fts_open
17745617Sbosticas a prefix.
17848352Scael.It Fa fts_pathlen
17945617SbosticThe length of the string referenced by
18048352Scael.Fa fts_path .
18148352Scael.It Fa fts_name
18245617SbosticThe name of the file.
18348352Scael.It Fa fts_namelen
18445617SbosticThe length of the string referenced by
18548352Scael.Fa fts_name .
18648352Scael.It Fa fts_level
18745617SbosticThe depth of the traversal, numbered from \-1 to N, where this file
18845617Sbosticwas found.
18948352ScaelThe
19048352Scael.Fa FTSENT
19148352Scaelstructure representing the parent of the starting point (or root)
19248352Scaelof the traversal is numbered \-1, and the
19348352Scael.Fa FTSENT
19448352Scaelstructure for the root
19545617Sbosticitself is numbered 0.
19648352Scael.It Fa fts_number
19745617SbosticThis field is provided for the use of the application program and is
19845617Sbosticnot modified by the
19948352Scael.Nm fts
20045617Sbosticfunctions.
20145617SbosticIt is initialized to 0.
20245617SbosticThe fields
20348352Scael.Fa fts_number
20445617Sbosticand
20548352Scael.Fa fts_pointer
20645617Sbosticoccupy the same physical location; using both may cause undefined results.
20748352Scael.It Fa fts_pointer
20845617SbosticThis field is provided for the use of the application program and is
20945617Sbosticnot modified by the
21048352Scael.Nm fts
21145617Sbosticfunctions.
21248352ScaelIt is initialized to
21348352Scael.Dv NULL .
21445617SbosticThe fields
21548352Scael.Fa fts_number
21645617Sbosticand
21748352Scael.Fa fts_pointer
21845617Sbosticoccupy the same physical location; using both may cause undefined results.
21948352Scael.It Fa fts_parent
22048352ScaelA pointer to the
22148352Scael.Fa FTSENT
22248352Scaelstructure referencing the file in the hierarchy
22345617Sbosticimmediately above the current file, i.e. the directory of which this
22445617Sbosticfile is a member.
22545617SbosticA parent structure for the initial entry point is provided as well,
22645617Sbostichowever, only the
22748352Scael.Fa fts_level ,
22848352Scael.Fa fts_number
22945617Sbosticand
23048352Scael.Fa fts_pointer
23145617Sbosticfields are guaranteed to be initialized.
23248352Scael.It Fa fts_link
233*52075SbosticUpon return from the
234*52075Sbostic.Fn fts_children
235*52075Sbosticfunction, the
23648352Scael.Fa fts_link
237*52075Sbosticfield points to the next structure in the NULL-terminated linked list of
238*52075Sbosticdirectory members.
239*52075SbosticOtherwise, the contents of the
240*52075Sbostic.Fa fts_link
241*52075Sbosticfield are undefined.
242*52075Sbostic.It Fa fts_cycle
24348352ScaelIf a directory causes a cycle in the hierarchy (see
24448352Scael.Dv FTS_DC ) ,
24548352Scaeleither because
24645617Sbosticof a hard link between two directories, or a symbolic link pointing to a
24745617Sbosticdirectory, the
248*52075Sbostic.Fa fts_cycle
24948352Scaelfield of the structure will point to the
25048352Scael.Fa FTSENT
251*52075Sbosticstructure in the hierarchy that references the same file as the current
25248352Scael.Fa FTSENT
25348352Scaelstructure.
25445617SbosticOtherwise, the contents of the
255*52075Sbostic.Fa fts_cycle
25645617Sbosticfield are undefined.
25748352Scael.It Fa fts_statb
25848352Scael.Xr Stat 2
25939801Sbosticinformation for the file.
26048352Scael.El
26148352Scael.Sh FTS_OPEN
26245617SbosticThe
26348352Scael.Fn fts_open
26445617Sbosticfunction takes a pointer to an array of character pointers naming one
26545617Sbosticor more paths which make up a logical file hierarchy to be traversed.
26648352ScaelThe array must be terminated by a
26748352Scael.Dv NULL
26848352Scaelpointer.
26948352Scael.Pp
27048352ScaelThere are
27148352Scaela number of options, at least one of which (either
27248352Scael.Dv FTS_LOGICAL
27348352Scaelor
27448352Scael.Dv FTS_PHYSICAL )
27548352Scaelmust be specified.
27645617SbosticThe options are selected by
27748352Scael.Em or Ns 'ing
27845617Sbosticthe following values:
27948352Scael.Bl -tag -width "FTS_PHYSICAL"
28048352Scael.It Dv FTS_LOGICAL
28145617SbosticThis option causes the
28248352Scael.Nm fts
28348352Scaelroutines to return
28448352Scael.Fa FTSENT
28548352Scaelstructures for the targets of symbolic links
28645617Sbosticinstead of the symbolic links themselves.
28748352ScaelIf this option is set, the only symbolic links for which
28848352Scael.Fa FTSENT
28948352Scaelstructures
29045617Sbosticare returned to the application are those referencing non-existent files.
29148352ScaelEither
29248352Scael.Dv FTS_LOGICAL
29348352Scaelor
29448352Scael.Dv FTS_PHYSICAL
29548352Scael.Em must
29645617Sbosticbe provided to the
29748352Scael.Fn fts_open
29845617Sbosticfunction.
29948352Scael.It Dv FTS_NOCHDIR
30045617SbosticAs a performance optimization, the
30148352Scael.Nm fts
30245617Sbosticfunctions change directories as they walk the file hierarchy.
30345617SbosticThis has the side-effect that an application cannot rely on being
30445617Sbosticin any particular directory during the traversal.
30548352ScaelThe
30648352Scael.Dv FTS_NOCHDIR
30748352Scaeloption turns off this optimization, and the
30848352Scael.Nm fts
30945617Sbosticfunctions will not change the current directory.
31045617SbosticNote that applications should not themselves change their current directory
31148352Scaeland try to access files unless
31248352Scael.Dv FTS_NOCHDIR
31348352Scaelis specified and absolute
31445617Sbosticpathnames were provided as arguments to
31548352Scael.Fn fts_open .
31648352Scael.It Dv FTS_NOSTAT
31748352ScaelBy default, returned
31848352Scael.Fa FTSENT
31948352Scaelstructures contain file characteristic
32045617Sbosticinformation (the
32148352Scael.Fa statb
32245617Sbosticfield) for each file visited.
32345617SbosticThis option relaxes that requirement as a performance optimization,
32445617Sbosticallowing the
32548352Scael.Nm fts
32645617Sbosticfunctions to set the
32748352Scael.Fa fts_info
32848352Scaelfield to
32948352Scael.Dv FTS_NSOK
33048352Scaeland leave the contents of the
33148352Scael.Fa statb
33245617Sbosticfield undefined.
33348352Scael.It Dv FTS_PHYSICAL
33445617SbosticThis option causes the
33548352Scael.Nm fts
33648352Scaelroutines to return
33748352Scael.Fa FTSENT
33848352Scaelstructures for symbolic links themselves instead
33945617Sbosticof the target files they point to.
34048352ScaelIf this option is set,
34148352Scael.Fa FTSENT
34248352Scaelstructures for all symbolic links in the
34345617Sbostichierarchy are returned to the application.
34448352ScaelEither
34548352Scael.Dv FTS_LOGICAL
34648352Scaelor
34748352Scael.Dv FTS_PHYSICAL
34848352Scael.Em must
34945617Sbosticbe provided to the
35048352Scael.Fn fts_open
35145617Sbosticfunction.
35248352Scael.It Dv FTS_SEEDOT
35345617SbosticBy default, unless they are specified as path arguments to
35448352Scael.Fn fts_open ,
35548352Scaelany files named
35648352Scael.Ql \&.
35752067Sbosticor
35848352Scael.Ql ..
35948352Scaelencountered in the file hierarchy are
36045617Sbosticignored.
36145617SbosticThis option causes the
36248352Scael.Nm fts
36348352Scaelroutines to return
36448352Scael.Fa FTSENT
36548352Scaelstructures for them.
36648352Scael.It Dv FTS_XDEV
36745617SbosticThis option prevents
36848352Scael.Nm fts
36945617Sbosticfrom descending into directories that have a different device number
37045617Sbosticthan the file from which the descent began.
37148352Scael.El
37248352Scael.Pp
37345617SbosticThe argument
37448352Scael.Fn compar
37545617Sbosticspecifies a user-defined function which may be used to order the traversal
37645617Sbosticof the hierarchy.
37748352ScaelIt
37848352Scaeltakes two pointers to pointers to
37948352Scael.Fa FTSENT
38048352Scaelstructures as arguments and
38145617Sbosticshould return a negative value, zero, or a positive value to indicate
38245617Sbosticif the file referenced by its first argument comes before, in any order
38345617Sbosticwith respect to, or after, the file referenced by its second argument.
38439801SbosticThe
38548352Scael.Fa fts_accpath ,
38648352Scael.Fa fts_path
38739801Sbosticand
38848352Scael.Fa fts_pathlen
38948352Scaelfields of the
39048352Scael.Fa FTSENT
39148352Scaelstructures may
39248352Scael.Em never
39345617Sbosticbe used in this comparison.
39447194SbosticIf the
39548352Scael.Fa fts_info
39648352Scaelfield is set to
39748352Scael.Dv FTS_NS
39848352Scaelor
39948352Scael.DV FTS_NSOK ,
40048352Scaelthe
40148352Scael.Fa fts_stab
40245617Sbosticfield may not either.
40345617SbosticIf the
40448352Scael.Fn compar
40548352Scaelargument is
40648352Scael.Dv NULL ,
40748352Scaelthe directory traversal order is unspecified except
40845617Sbosticfor the root paths which are traversed in the order listed in
40948352Scael.Fa path_argv .
41048352Scael.Sh FTS_READ
41139801SbosticThe
41248352Scael.Fn fts_read
41348352Scaelfunction returns a pointer to an
41448352Scael.Fa FTSENT
41548352Scaelstructure describing a file in
41645617Sbosticthe hierarchy.
41747194SbosticDirectories (that are readable and do not cause cycles) are visited at
41847194Sbosticleast twice, once in pre-order and once in post-order.
41945617SbosticAll other files are visited at least once.
42045617Sbostic(Hard links between directories that do not cause cycles or symbolic
42145617Sbosticlinks to symbolic links may cause files to be visited more than once,
42245617Sbosticor directories more than twice.)
42348352Scael.Pp
42439801SbosticIf all the members of the hierarchy have been returned,
42548352Scael.Fn fts_read
42648352Scaelreturns
42748352Scael.Dv NULL
42848352Scaeland sets the external variable
42948352Scael.Va errno
43039801Sbosticto 0.
43139801SbosticIf an error unrelated to a file in the hierarchy occurs,
43248352Scael.Fn fts_read
43348352Scaelreturns
43448352Scael.Dv NULL
43548352Scaeland sets
43648352Scael.Va errno
43745617Sbosticappropriately.
43848352ScaelIf an error related to a returned file occurs, a pointer to an
43948352Scael.Fa FTSENT
44045617Sbosticstructure is returned, and
44148352Scael.Va errno
44245617Sbosticmay or may not have been set (see
44348352Scael.Fa fts_info ) .
44448352Scael.Pp
44548352ScaelThe
44648352Scael.Fa FTSENT
44748352Scaelstructures returned by
44848352Scael.Fn fts_read
44945617Sbosticmay be overwritten after a call to
45048352Scael.Fn fts_close
45145617Sbosticon the same file hierarchy stream, or, after a call to
45248352Scael.Fn fts_read
45345617Sbosticon the same file hierarchy stream unless they represent a file of type
45445617Sbosticdirectory, in which case they will not be overwritten until after a call to
45548352Scael.Fn fts_read
45648352Scaelafter the
45748352Scael.Fa FTSENT
45848352Scaelstructure has been returned by the function
45948352Scael.Fn fts_read
46045617Sbosticin post-order.
46148352Scael.Sh FTS_CHILDREN
46245617SbosticThe
46348352Scael.Fn fts_children
46448352Scaelfunction returns a pointer to an
46548352Scael.Fa FTSENT
46648352Scaelstructure describing the first
467*52075Sbosticentry in a NULL-terminated linked list of the files in the directory
468*52075Sbosticrepresented by the
46948352Scael.Fa FTSENT
47048352Scaelstructure most recently returned by
47148352Scael.Fn fts_read .
47245617SbosticThe list is linked through the
47348352Scael.Fa fts_link
47448352Scaelfield of the
47548352Scael.Fa FTSENT
47648352Scaelstructure, and is ordered by the user-specified
47745617Sbosticcomparison function, if any.
47845617SbosticRepeated calls to
47948352Scael.Fn fts_children
48045617Sbosticwill recreate this linked list.
48148352Scael.Pp
48248352ScaelIf the
48348352Scael.Fa FTSENT
48448352Scaelstructure most recently returned by
48548352Scael.Fn fts_read
48645617Sbosticis not a directory being visited in pre-order,
48745617Sbosticor the directory does not contain any files,
48848352Scael.Fn fts_children
48948352Scaelreturns
49048352Scael.Dv NULL
49148352Scaeland sets
49248352Scael.Va errno
49345617Sbosticto zero.
49439801SbosticIf an error occurs,
49548352Scael.Fn fts_children
49648352Scaelreturns
49748352Scael.Dv NULL
49848352Scaeland sets
49948352Scael.Va errno
50045617Sbosticappropriately.
50148352Scael.Pp
50248352ScaelThe
50348352Scael.Fa FTSENT
50448352Scaelstructures returned by
50548352Scael.Fn fts_children
50639801Sbosticmay be overwritten after a call to
507*52075Sbostic.Fn fts_children ,
50848352Scael.Fn fts_close
50939801Sbosticor
51048352Scael.Fn fts_read
51145617Sbosticon the same file hierarchy stream.
51248352Scael.Pp
51345617SbosticA single buffer is used for all of the paths of all of the files in the
51445617Sbosticfile hierarchy.
51545617SbosticTherefore, the
51648352Scael.Fa fts_path
51745617Sbosticand
51848352Scael.Fa fts_accpath
51948352Scaelfields are guaranteed to be
52048352Scael.Dv NULL Ns -terminated
52148352Scael.Em only
52245617Sbosticfor the file most recently returned by
52348352Scael.Fn fts_read .
52448352ScaelTo use these fields to reference any files represented by other
52548352Scael.Fa FTSENT
52645617Sbosticstructures will require that the path buffer be modified using the
52748352Scaelinformation contained in that
52848352Scael.Fa FTSENT
52948352Scaelstructure's
53048352Scael.Fa fts_pathlen
53145617Sbosticfield.
53245617SbosticAny such modifications should be undone before further calls to
53348352Scael.Fn fts_read
53445617Sbosticare attempted.
53545617SbosticThe
53648352Scael.Fa fts_name
53748352Scaelfield is always
53848352Scael.Dv NULL Ns -terminated.
53948352Scael.Sh FTS_SET
54045617SbosticThe function
54148352Scael.Fn fts_set
54239801Sbosticallows the user application to determine further processing for the
54339801Sbosticfile
54448352Scael.Fa f
54539801Sbosticof the stream
54648352Scael.Fa ftsp .
54748352ScaelThe
54848352Scael.Fn fts_set
54948352Scaelfunction
55048352Scaelreturns 0 on success, and \-1 if an error occurs.
55148352Scael.Em Option
55245617Sbosticmust be set to one of the following values:
55348352Scael.Bl -tag -width FTS_PHYSICAL
55448352Scael.It Dv FTS_AGAIN
55539801SbosticRe-visit the file; any file type may be re-visited.
55639801SbosticThe next call to
55748352Scael.Fn fts_read
55839801Sbosticwill return the referenced file.
55945617SbosticThe
56048352Scael.Fa fts_stat
56139801Sbosticand
56248352Scael.Fa fts_info
56339801Sbosticfields of the structure will be reinitialized at that time,
56445617Sbosticbut no other fields will have been changed.
56539801SbosticThis option is meaningful only for the most recently returned
56639801Sbosticfile from
56748352Scael.Fn fts_read .
56839801SbosticNormal use is for post-order directory visits, where it causes the
56939801Sbosticdirectory to be re-visited (in both pre and post-order) as well as all
57039801Sbosticof its descendants.
57148352Scael.It Dv FTS_FOLLOW
57239801SbosticThe referenced file must be a symbolic link.
57339801SbosticIf the referenced file is the one most recently returned by
57448352Scael.Fn fts_read ,
57539801Sbosticthe next call to
57648352Scael.Fn fts_read
57739801Sbosticreturns the file with the
57848352Scael.Fa fts_info
57939801Sbosticand
58048352Scael.Fa fts_statb
58139801Sbosticfields reinitialized to reflect the target of the symbolic link instead
58239801Sbosticof the symbolic link itself.
58339801SbosticIf the file is one of those most recently returned by
58448352Scael.Fn fts_children ,
58539801Sbosticthe
58648352Scael.Fa fts_info
58739801Sbosticand
58848352Scael.Fa fts_statb
58939801Sbosticfields of the structure, when returned by
59048352Scael.Fn fts_read ,
59139801Sbosticwill reflect the target of the symbolic link instead of the symbolic link
59239801Sbosticitself.
59347194SbosticIn either case, if the target of the symbolic link does not exist the
59447194Sbosticfields of the returned structure will be unchanged and the
59548352Scael.Fa fts_info
59648352Scaelfield will be set to
59748352Scael.Dv FTS_SLNONE .
59848352Scael.Pp
59947194SbosticIf the target of the link is a directory, the pre-order return, followed
60047194Sbosticby the return of all of its descendants, followed by a post-order return,
60147194Sbosticis done.
60248352Scael.It Dv FTS_SKIP
60339801SbosticNo descendants of this file are visited.
60445617SbosticThe file may be one of those most recently returned by either
60548352Scael.Fn fts_children
60645617Sbosticor
60748352Scael.Fn fts_read .
60848352Scael.El
60948352Scael.Sh FTS_CLOSE
61045617SbosticThe
61148352Scael.Fn fts_close
61245617Sbosticfunction closes a file hierarchy stream
61348352Scael.Fa ftsp
61445617Sbosticand restores the current directory to the directory from which
61548352Scael.Fn fts_open
61645617Sbosticwas called to open
61748352Scael.Fa ftsp .
61848352ScaelThe
61948352Scael.Fn fts_close
62048352Scaelfunction
62148352Scaelreturns 0 on success, and \-1 if an error occurs.
62248352Scael.Sh ERRORS
62348352ScaelThe function
62448352Scael.Fn fts_open
62539801Sbosticmay fail and set errno for any of the errors specified for the library
62645661Sbosticfunctions
62748352Scael.Xr open 2
62845661Sbosticand
62948352Scael.Xr malloc 3 .
63048352Scael.Pp
63148352ScaelThe function
63248352Scael.Fn fts_close
63339801Sbosticmay fail and set errno for any of the errors specified for the library
63445661Sbosticfunctions
63548352Scael.Xr chdir 2
63645661Sbosticand
63748352Scael.Xr close 2 .
63848352Scael.Pp
63948352ScaelThe functions
64050943Sbostic.Fn fts_read
64139801Sbosticand
64248352Scael.Fn fts_children
64339801Sbosticmay fail and set errno for any of the errors specified for the library
64445617Sbosticfunctions
64548352Scael.Xr chdir 2 ,
64648352Scael.Xr malloc 3 ,
64748352Scael.Xr opendir 3 ,
64848352Scael.Xr readdir 3
64939801Sbosticand
65048352Scael.Xr stat 2 .
65148352Scael.Sh SEE ALSO
65248352Scael.Xr find 1 ,
65348352Scael.Xr chdir 2 ,
65448352Scael.Xr stat 2 ,
65548352Scael.Xr qsort 3
65648352Scael.Sh STANDARDS
65739801SbosticThe
65848352Scael.Nm fts
65948352Scaelutility is expected to be a superset of the
66048352Scael.St -p1003.1-88
66147194Sbosticspecification.
662