xref: /csrg-svn/lib/libc/gen/fts.3 (revision 52067)
148352Scael.\" Copyright (c) 1989, 1991 The Regents of the University of California.
239801Sbostic.\" All rights reserved.
339801Sbostic.\"
443571Strent.\" %sccs.include.redist.man%
539801Sbostic.\"
6*52067Sbostic.\"     @(#)fts.3	5.13 (Berkeley) 12/26/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 */
9048352Scael	struct ftsent *fts_link;	/* cycle or next file structure */
9148352Scael	struct stat fts_statb;		/* stat(2) information */
9239801Sbostic} FTSENT;
9348352Scael.Ed
9448352Scael.Pp
9545617SbosticThese fields are defined as follows:
9648352Scael.Bl -tag -width "fts_namelen"
9748352Scael.It Fa fts_info
9848352ScaelOne of the following flags describing the returned
9948352Scael.Fa FTSENT
10048352Scaelstructure and
10145617Sbosticthe file it represents.
10248352ScaelWith the exception of directories without errors
10348352Scael.Pq Dv FTS_D ,
10448352Scaelall of these
10545617Sbosticentries are terminal, that is, they will not be revisited, nor will any
10645617Sbosticof their descendants be visited.
10748352Scael.Bl  -tag -width FTS_DEFAULT
10848352Scael.It Dv FTS_D
10939801SbosticA directory being visited in pre-order.
11048352Scael.It Dv FTS_DC
11145617SbosticA directory that causes a cycle in the tree.
11245617Sbostic(The
11348352Scael.Fa fts_link
11448352Scaelfield of the
11548352Scael.Fa FTSENT
11648352Scaelstructure will be filled in as well.)
11748352Scael.It Dv FTS_DEFAULT
11848352ScaelAny
11948352Scael.Fa FTSENT
12048352Scaelstructure that represents a file type not explicitly described
12145617Sbosticby one of the other
12248352Scael.Fa fts_info
12345617Sbosticvalues.
12448352Scael.It Dv FTS_DNR
12545617SbosticA directory which cannot be read.
12647194SbosticAn error return; the external variable
12748352Scael.Va errno
12847194Sbosticwill be set to indicate the error.
12948352Scael.It Dv FTS_DP
13045617SbosticA directory being visited in post-order.
13148352ScaelThe contents of the
13248352Scael.Fa FTSENT
13348352Scaelstructure will be unchanged from when
13445617Sbosticit was returned in pre-order, i.e. with the
13548352Scael.Fa fts_info
13648352Scaelfield set to
13748352Scael.Dv FTS_D .
13848352Scael.It Dv FTS_ERR
13945617SbosticAn error return; the external variable
14048352Scael.Va errno
14145617Sbosticwill be set to indicate the error.
14248352Scael.It Dv FTS_F
14339801SbosticA regular file.
14448352Scael.It Dv FTS_NS
14545617SbosticA file for which no
14648352Scael.Xr stat 2
14747194Sbosticinformation was available.
14847194SbosticThe contents of the
14948352Scael.Fa fts_statb
15039801Sbosticfield are undefined.
15147194SbosticAn error return; the external variable
15248352Scael.Va errno
15347194Sbosticwill be set to indicate the error.
15448352Scael.It Dv FTS_NSOK
15547194SbosticA file for which no
15648352Scael.Xr stat 2
15747194Sbosticinformation was requested.
15847194SbosticThe contents of the
15948352Scael.Fa fts_statb
16047194Sbosticfield are undefined.
16148352Scael.It Dv FTS_SL
16239801SbosticA symbolic link.
16348352Scael.It Dv FTS_SLNONE
16439801SbosticA symbolic link with a non-existent target.
16547194SbosticThe contents of the
16648352Scael.Fa fts_statb
16747194Sbosticfield contain the file characteristic information for the symbolic link
16847194Sbosticitself.
16948352Scael.El
17048352Scael.It Fa fts_accpath
17147194SbosticA path for accessing the file from the current directory.
17248352Scael.It Fa fts_path
17345617SbosticThe path for the file relative to the root of the traversal.
17445617SbosticThis path contains the path specified to
17548352Scael.Fn fts_open
17645617Sbosticas a prefix.
17748352Scael.It Fa fts_pathlen
17845617SbosticThe length of the string referenced by
17948352Scael.Fa fts_path .
18048352Scael.It Fa fts_name
18145617SbosticThe name of the file.
18248352Scael.It Fa fts_namelen
18345617SbosticThe length of the string referenced by
18448352Scael.Fa fts_name .
18548352Scael.It Fa fts_level
18645617SbosticThe depth of the traversal, numbered from \-1 to N, where this file
18745617Sbosticwas found.
18848352ScaelThe
18948352Scael.Fa FTSENT
19048352Scaelstructure representing the parent of the starting point (or root)
19148352Scaelof the traversal is numbered \-1, and the
19248352Scael.Fa FTSENT
19348352Scaelstructure for the root
19445617Sbosticitself is numbered 0.
19548352Scael.It Fa fts_number
19645617SbosticThis field is provided for the use of the application program and is
19745617Sbosticnot modified by the
19848352Scael.Nm fts
19945617Sbosticfunctions.
20045617SbosticIt is initialized to 0.
20145617SbosticThe fields
20248352Scael.Fa fts_number
20345617Sbosticand
20448352Scael.Fa fts_pointer
20545617Sbosticoccupy the same physical location; using both may cause undefined results.
20648352Scael.It Fa fts_pointer
20745617SbosticThis field is provided for the use of the application program and is
20845617Sbosticnot modified by the
20948352Scael.Nm fts
21045617Sbosticfunctions.
21148352ScaelIt is initialized to
21248352Scael.Dv NULL .
21345617SbosticThe fields
21448352Scael.Fa fts_number
21545617Sbosticand
21648352Scael.Fa fts_pointer
21745617Sbosticoccupy the same physical location; using both may cause undefined results.
21848352Scael.It Fa fts_parent
21948352ScaelA pointer to the
22048352Scael.Fa FTSENT
22148352Scaelstructure referencing the file in the hierarchy
22245617Sbosticimmediately above the current file, i.e. the directory of which this
22345617Sbosticfile is a member.
22445617SbosticA parent structure for the initial entry point is provided as well,
22545617Sbostichowever, only the
22648352Scael.Fa fts_level ,
22748352Scael.Fa fts_number
22845617Sbosticand
22948352Scael.Fa fts_pointer
23045617Sbosticfields are guaranteed to be initialized.
23148352Scael.It Fa fts_link
23245617SbosticThe
23348352Scael.Fa fts_link
23445617Sbosticfield has two separate uses.
23548352ScaelIf a directory causes a cycle in the hierarchy (see
23648352Scael.Dv FTS_DC ) ,
23748352Scaeleither because
23845617Sbosticof a hard link between two directories, or a symbolic link pointing to a
23945617Sbosticdirectory, the
24048352Scael.Fa fts_link
24148352Scaelfield of the structure will point to the
24248352Scael.Fa FTSENT
24348352Scaelstructure in the hierarchy
24448352Scaelthat references the same file as the current
24548352Scael.Fa FTSENT
24648352Scaelstructure.
24745617SbosticAlso, upon return from the
24848352Scael.Fn fts_children
24945617Sbosticfunction, the
25048352Scael.Fa fts_link
25145617Sbosticfield points to the next structure in the linked list of directory members.
25245617SbosticOtherwise, the contents of the
25348352Scael.Fa fts_link
25445617Sbosticfield are undefined.
25548352Scael.It Fa fts_statb
25648352Scael.Xr Stat 2
25739801Sbosticinformation for the file.
25848352Scael.El
25948352Scael.Sh FTS_OPEN
26045617SbosticThe
26148352Scael.Fn fts_open
26245617Sbosticfunction takes a pointer to an array of character pointers naming one
26345617Sbosticor more paths which make up a logical file hierarchy to be traversed.
26448352ScaelThe array must be terminated by a
26548352Scael.Dv NULL
26648352Scaelpointer.
26748352Scael.Pp
26848352ScaelThere are
26948352Scaela number of options, at least one of which (either
27048352Scael.Dv FTS_LOGICAL
27148352Scaelor
27248352Scael.Dv FTS_PHYSICAL )
27348352Scaelmust be specified.
27445617SbosticThe options are selected by
27548352Scael.Em or Ns 'ing
27645617Sbosticthe following values:
27748352Scael.Bl -tag -width "FTS_PHYSICAL"
27848352Scael.It Dv FTS_LOGICAL
27945617SbosticThis option causes the
28048352Scael.Nm fts
28148352Scaelroutines to return
28248352Scael.Fa FTSENT
28348352Scaelstructures for the targets of symbolic links
28445617Sbosticinstead of the symbolic links themselves.
28548352ScaelIf this option is set, the only symbolic links for which
28648352Scael.Fa FTSENT
28748352Scaelstructures
28845617Sbosticare returned to the application are those referencing non-existent files.
28948352ScaelEither
29048352Scael.Dv FTS_LOGICAL
29148352Scaelor
29248352Scael.Dv FTS_PHYSICAL
29348352Scael.Em must
29445617Sbosticbe provided to the
29548352Scael.Fn fts_open
29645617Sbosticfunction.
29748352Scael.It Dv FTS_NOCHDIR
29845617SbosticAs a performance optimization, the
29948352Scael.Nm fts
30045617Sbosticfunctions change directories as they walk the file hierarchy.
30145617SbosticThis has the side-effect that an application cannot rely on being
30245617Sbosticin any particular directory during the traversal.
30348352ScaelThe
30448352Scael.Dv FTS_NOCHDIR
30548352Scaeloption turns off this optimization, and the
30648352Scael.Nm fts
30745617Sbosticfunctions will not change the current directory.
30845617SbosticNote that applications should not themselves change their current directory
30948352Scaeland try to access files unless
31048352Scael.Dv FTS_NOCHDIR
31148352Scaelis specified and absolute
31245617Sbosticpathnames were provided as arguments to
31348352Scael.Fn fts_open .
31448352Scael.It Dv FTS_NOSTAT
31548352ScaelBy default, returned
31648352Scael.Fa FTSENT
31748352Scaelstructures contain file characteristic
31845617Sbosticinformation (the
31948352Scael.Fa statb
32045617Sbosticfield) for each file visited.
32145617SbosticThis option relaxes that requirement as a performance optimization,
32245617Sbosticallowing the
32348352Scael.Nm fts
32445617Sbosticfunctions to set the
32548352Scael.Fa fts_info
32648352Scaelfield to
32748352Scael.Dv FTS_NSOK
32848352Scaeland leave the contents of the
32948352Scael.Fa statb
33045617Sbosticfield undefined.
33148352Scael.It Dv FTS_PHYSICAL
33245617SbosticThis option causes the
33348352Scael.Nm fts
33448352Scaelroutines to return
33548352Scael.Fa FTSENT
33648352Scaelstructures for symbolic links themselves instead
33745617Sbosticof the target files they point to.
33848352ScaelIf this option is set,
33948352Scael.Fa FTSENT
34048352Scaelstructures for all symbolic links in the
34145617Sbostichierarchy are returned to the application.
34248352ScaelEither
34348352Scael.Dv FTS_LOGICAL
34448352Scaelor
34548352Scael.Dv FTS_PHYSICAL
34648352Scael.Em must
34745617Sbosticbe provided to the
34848352Scael.Fn fts_open
34945617Sbosticfunction.
35048352Scael.It Dv FTS_SEEDOT
35145617SbosticBy default, unless they are specified as path arguments to
35248352Scael.Fn fts_open ,
35348352Scaelany files named
35448352Scael.Ql \&.
355*52067Sbosticor
35648352Scael.Ql ..
35748352Scaelencountered in the file hierarchy are
35845617Sbosticignored.
35945617SbosticThis option causes the
36048352Scael.Nm fts
36148352Scaelroutines to return
36248352Scael.Fa FTSENT
36348352Scaelstructures for them.
36448352Scael.It Dv FTS_XDEV
36545617SbosticThis option prevents
36648352Scael.Nm fts
36745617Sbosticfrom descending into directories that have a different device number
36845617Sbosticthan the file from which the descent began.
36948352Scael.El
37048352Scael.Pp
37145617SbosticThe argument
37248352Scael.Fn compar
37345617Sbosticspecifies a user-defined function which may be used to order the traversal
37445617Sbosticof the hierarchy.
37548352ScaelIt
37648352Scaeltakes two pointers to pointers to
37748352Scael.Fa FTSENT
37848352Scaelstructures as arguments and
37945617Sbosticshould return a negative value, zero, or a positive value to indicate
38045617Sbosticif the file referenced by its first argument comes before, in any order
38145617Sbosticwith respect to, or after, the file referenced by its second argument.
38239801SbosticThe
38348352Scael.Fa fts_accpath ,
38448352Scael.Fa fts_path
38539801Sbosticand
38648352Scael.Fa fts_pathlen
38748352Scaelfields of the
38848352Scael.Fa FTSENT
38948352Scaelstructures may
39048352Scael.Em never
39145617Sbosticbe used in this comparison.
39247194SbosticIf the
39348352Scael.Fa fts_info
39448352Scaelfield is set to
39548352Scael.Dv FTS_NS
39648352Scaelor
39748352Scael.DV FTS_NSOK ,
39848352Scaelthe
39948352Scael.Fa fts_stab
40045617Sbosticfield may not either.
40145617SbosticIf the
40248352Scael.Fn compar
40348352Scaelargument is
40448352Scael.Dv NULL ,
40548352Scaelthe directory traversal order is unspecified except
40645617Sbosticfor the root paths which are traversed in the order listed in
40748352Scael.Fa path_argv .
40848352Scael.Sh FTS_READ
40939801SbosticThe
41048352Scael.Fn fts_read
41148352Scaelfunction returns a pointer to an
41248352Scael.Fa FTSENT
41348352Scaelstructure describing a file in
41445617Sbosticthe hierarchy.
41547194SbosticDirectories (that are readable and do not cause cycles) are visited at
41647194Sbosticleast twice, once in pre-order and once in post-order.
41745617SbosticAll other files are visited at least once.
41845617Sbostic(Hard links between directories that do not cause cycles or symbolic
41945617Sbosticlinks to symbolic links may cause files to be visited more than once,
42045617Sbosticor directories more than twice.)
42148352Scael.Pp
42239801SbosticIf all the members of the hierarchy have been returned,
42348352Scael.Fn fts_read
42448352Scaelreturns
42548352Scael.Dv NULL
42648352Scaeland sets the external variable
42748352Scael.Va errno
42839801Sbosticto 0.
42939801SbosticIf an error unrelated to a file in the hierarchy occurs,
43048352Scael.Fn fts_read
43148352Scaelreturns
43248352Scael.Dv NULL
43348352Scaeland sets
43448352Scael.Va errno
43545617Sbosticappropriately.
43648352ScaelIf an error related to a returned file occurs, a pointer to an
43748352Scael.Fa FTSENT
43845617Sbosticstructure is returned, and
43948352Scael.Va errno
44045617Sbosticmay or may not have been set (see
44148352Scael.Fa fts_info ) .
44248352Scael.Pp
44348352ScaelThe
44448352Scael.Fa FTSENT
44548352Scaelstructures returned by
44648352Scael.Fn fts_read
44745617Sbosticmay be overwritten after a call to
44848352Scael.Fn fts_close
44945617Sbosticon the same file hierarchy stream, or, after a call to
45048352Scael.Fn fts_read
45145617Sbosticon the same file hierarchy stream unless they represent a file of type
45245617Sbosticdirectory, in which case they will not be overwritten until after a call to
45348352Scael.Fn fts_read
45448352Scaelafter the
45548352Scael.Fa FTSENT
45648352Scaelstructure has been returned by the function
45748352Scael.Fn fts_read
45845617Sbosticin post-order.
45948352Scael.Sh FTS_CHILDREN
46045617SbosticThe
46148352Scael.Fn fts_children
46248352Scaelfunction returns a pointer to an
46348352Scael.Fa FTSENT
46448352Scaelstructure describing the first
46545617Sbosticentry in a linked list of the files in the directory represented by the
46648352Scael.Fa FTSENT
46748352Scaelstructure most recently returned by
46848352Scael.Fn fts_read .
46945617SbosticThe list is linked through the
47048352Scael.Fa fts_link
47148352Scaelfield of the
47248352Scael.Fa FTSENT
47348352Scaelstructure, and is ordered by the user-specified
47445617Sbosticcomparison function, if any.
47545617SbosticRepeated calls to
47648352Scael.Fn fts_children
47745617Sbosticwill recreate this linked list.
47848352Scael.Pp
47948352ScaelIf the
48048352Scael.Fa FTSENT
48148352Scaelstructure most recently returned by
48248352Scael.Fn fts_read
48345617Sbosticis not a directory being visited in pre-order,
48445617Sbosticor the directory does not contain any files,
48548352Scael.Fn fts_children
48648352Scaelreturns
48748352Scael.Dv NULL
48848352Scaeland sets
48948352Scael.Va errno
49045617Sbosticto zero.
49139801SbosticIf an error occurs,
49248352Scael.Fn fts_children
49348352Scaelreturns
49448352Scael.Dv NULL
49548352Scaeland sets
49648352Scael.Va errno
49745617Sbosticappropriately.
49848352Scael.Pp
49948352ScaelThe
50048352Scael.Fa FTSENT
50148352Scaelstructures returned by
50248352Scael.Fn fts_children
50339801Sbosticmay be overwritten after a call to
50448352Scael.Fn fts_close
50545617Sbosticon the same file hierarchy stream, or after a call to
50648352Scael.Fn fts_children
50739801Sbosticor
50848352Scael.Fn fts_read
50945617Sbosticon the same file hierarchy stream.
51048352Scael.Pp
51145617SbosticA single buffer is used for all of the paths of all of the files in the
51245617Sbosticfile hierarchy.
51345617SbosticTherefore, the
51448352Scael.Fa fts_path
51545617Sbosticand
51648352Scael.Fa fts_accpath
51748352Scaelfields are guaranteed to be
51848352Scael.Dv NULL Ns -terminated
51948352Scael.Em only
52045617Sbosticfor the file most recently returned by
52148352Scael.Fn fts_read .
52248352ScaelTo use these fields to reference any files represented by other
52348352Scael.Fa FTSENT
52445617Sbosticstructures will require that the path buffer be modified using the
52548352Scaelinformation contained in that
52648352Scael.Fa FTSENT
52748352Scaelstructure's
52848352Scael.Fa fts_pathlen
52945617Sbosticfield.
53045617SbosticAny such modifications should be undone before further calls to
53148352Scael.Fn fts_read
53245617Sbosticare attempted.
53345617SbosticThe
53448352Scael.Fa fts_name
53548352Scaelfield is always
53648352Scael.Dv NULL Ns -terminated.
53748352Scael.Sh FTS_SET
53845617SbosticThe function
53948352Scael.Fn fts_set
54039801Sbosticallows the user application to determine further processing for the
54139801Sbosticfile
54248352Scael.Fa f
54339801Sbosticof the stream
54448352Scael.Fa ftsp .
54548352ScaelThe
54648352Scael.Fn fts_set
54748352Scaelfunction
54848352Scaelreturns 0 on success, and \-1 if an error occurs.
54948352Scael.Em Option
55045617Sbosticmust be set to one of the following values:
55148352Scael.Bl -tag -width FTS_PHYSICAL
55248352Scael.It Dv FTS_AGAIN
55339801SbosticRe-visit the file; any file type may be re-visited.
55439801SbosticThe next call to
55548352Scael.Fn fts_read
55639801Sbosticwill return the referenced file.
55745617SbosticThe
55848352Scael.Fa fts_stat
55939801Sbosticand
56048352Scael.Fa fts_info
56139801Sbosticfields of the structure will be reinitialized at that time,
56245617Sbosticbut no other fields will have been changed.
56339801SbosticThis option is meaningful only for the most recently returned
56439801Sbosticfile from
56548352Scael.Fn fts_read .
56639801SbosticNormal use is for post-order directory visits, where it causes the
56739801Sbosticdirectory to be re-visited (in both pre and post-order) as well as all
56839801Sbosticof its descendants.
56948352Scael.It Dv FTS_FOLLOW
57039801SbosticThe referenced file must be a symbolic link.
57139801SbosticIf the referenced file is the one most recently returned by
57248352Scael.Fn fts_read ,
57339801Sbosticthe next call to
57448352Scael.Fn fts_read
57539801Sbosticreturns the file with the
57648352Scael.Fa fts_info
57739801Sbosticand
57848352Scael.Fa fts_statb
57939801Sbosticfields reinitialized to reflect the target of the symbolic link instead
58039801Sbosticof the symbolic link itself.
58139801SbosticIf the file is one of those most recently returned by
58248352Scael.Fn fts_children ,
58339801Sbosticthe
58448352Scael.Fa fts_info
58539801Sbosticand
58648352Scael.Fa fts_statb
58739801Sbosticfields of the structure, when returned by
58848352Scael.Fn fts_read ,
58939801Sbosticwill reflect the target of the symbolic link instead of the symbolic link
59039801Sbosticitself.
59147194SbosticIn either case, if the target of the symbolic link does not exist the
59247194Sbosticfields of the returned structure will be unchanged and the
59348352Scael.Fa fts_info
59448352Scaelfield will be set to
59548352Scael.Dv FTS_SLNONE .
59648352Scael.Pp
59747194SbosticIf the target of the link is a directory, the pre-order return, followed
59847194Sbosticby the return of all of its descendants, followed by a post-order return,
59947194Sbosticis done.
60048352Scael.It Dv FTS_SKIP
60139801SbosticNo descendants of this file are visited.
60245617SbosticThe file may be one of those most recently returned by either
60348352Scael.Fn fts_children
60445617Sbosticor
60548352Scael.Fn fts_read .
60648352Scael.El
60748352Scael.Sh FTS_CLOSE
60845617SbosticThe
60948352Scael.Fn fts_close
61045617Sbosticfunction closes a file hierarchy stream
61148352Scael.Fa ftsp
61245617Sbosticand restores the current directory to the directory from which
61348352Scael.Fn fts_open
61445617Sbosticwas called to open
61548352Scael.Fa ftsp .
61648352ScaelThe
61748352Scael.Fn fts_close
61848352Scaelfunction
61948352Scaelreturns 0 on success, and \-1 if an error occurs.
62048352Scael.Sh ERRORS
62148352ScaelThe function
62248352Scael.Fn fts_open
62339801Sbosticmay fail and set errno for any of the errors specified for the library
62445661Sbosticfunctions
62548352Scael.Xr open 2
62645661Sbosticand
62748352Scael.Xr malloc 3 .
62848352Scael.Pp
62948352ScaelThe function
63048352Scael.Fn fts_close
63139801Sbosticmay fail and set errno for any of the errors specified for the library
63245661Sbosticfunctions
63348352Scael.Xr chdir 2
63445661Sbosticand
63548352Scael.Xr close 2 .
63648352Scael.Pp
63748352ScaelThe functions
63850943Sbostic.Fn fts_read
63939801Sbosticand
64048352Scael.Fn fts_children
64139801Sbosticmay fail and set errno for any of the errors specified for the library
64245617Sbosticfunctions
64348352Scael.Xr chdir 2 ,
64448352Scael.Xr malloc 3 ,
64548352Scael.Xr opendir 3 ,
64648352Scael.Xr readdir 3
64739801Sbosticand
64848352Scael.Xr stat 2 .
64948352Scael.Sh SEE ALSO
65048352Scael.Xr find 1 ,
65148352Scael.Xr chdir 2 ,
65248352Scael.Xr stat 2 ,
65348352Scael.Xr qsort 3
65448352Scael.Sh STANDARDS
65539801SbosticThe
65648352Scael.Nm fts
65748352Scaelutility is expected to be a superset of the
65848352Scael.St -p1003.1-88
65947194Sbosticspecification.
660