]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/gen/fts.3
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / gen / fts.3
1 .\" Copyright (c) 1989, 1991, 1993, 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)fts.3       8.5 (Berkeley) 4/16/94
29 .\" $FreeBSD$
30 .\"
31 .Dd March 18, 2012
32 .Dt FTS 3
33 .Os
34 .Sh NAME
35 .Nm fts
36 .Nd traverse a file hierarchy
37 .Sh LIBRARY
38 .Lb libc
39 .Sh SYNOPSIS
40 .In sys/types.h
41 .In sys/stat.h
42 .In fts.h
43 .Ft FTS *
44 .Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)"
45 .Ft FTSENT *
46 .Fn fts_read "FTS *ftsp"
47 .Ft FTSENT *
48 .Fn fts_children "FTS *ftsp" "int options"
49 .Ft int
50 .Fn fts_set "FTS *ftsp" "FTSENT *f" "int options"
51 .Ft void
52 .Fn fts_set_clientptr "FTS *ftsp" "void *clientdata"
53 .Ft void *
54 .Fn fts_get_clientptr "FTS *ftsp"
55 .Ft FTS *
56 .Fn fts_get_stream "FTSENT *f"
57 .Ft int
58 .Fn fts_close "FTS *ftsp"
59 .Sh DESCRIPTION
60 The
61 .Nm
62 functions are provided for traversing
63 .Ux
64 file hierarchies.
65 A simple overview is that the
66 .Fn fts_open
67 function returns a
68 .Dq handle
69 on a file hierarchy, which is then supplied to
70 the other
71 .Nm
72 functions.
73 The function
74 .Fn fts_read
75 returns a pointer to a structure describing one of the files in the file
76 hierarchy.
77 The function
78 .Fn fts_children
79 returns a pointer to a linked list of structures, each of which describes
80 one of the files contained in a directory in the hierarchy.
81 In general, directories are visited two distinguishable times; in pre-order
82 (before any of their descendants are visited) and in post-order (after all
83 of their descendants have been visited).
84 Files are visited once.
85 It is possible to walk the hierarchy
86 .Dq logically
87 (ignoring symbolic links)
88 or physically (visiting symbolic links), order the walk of the hierarchy or
89 prune and/or re-visit portions of the hierarchy.
90 .Pp
91 Two structures are defined (and typedef'd) in the include file
92 .In fts.h .
93 The first is
94 .Vt FTS ,
95 the structure that represents the file hierarchy itself.
96 The second is
97 .Vt FTSENT ,
98 the structure that represents a file in the file
99 hierarchy.
100 Normally, an
101 .Vt FTSENT
102 structure is returned for every file in the file
103 hierarchy.
104 In this manual page,
105 .Dq file
106 and
107 .Dq Vt FTSENT No structure
108 are generally
109 interchangeable.
110 .Pp
111 The
112 .Vt FTS
113 structure contains space for a single pointer, which may be used to
114 store application data or per-hierarchy state.
115 The
116 .Fn fts_set_clientptr
117 and
118 .Fn fts_get_clientptr
119 functions may be used to set and retrieve this pointer.
120 This is likely to be useful only when accessed from the sort
121 comparison function, which can determine the original
122 .Vt FTS
123 stream of its arguments using the
124 .Fn fts_get_stream
125 function.
126 The two
127 .Li get
128 functions are also available as macros of the same name.
129 .Pp
130 The
131 .Vt FTSENT
132 structure contains at least the following fields, which are
133 described in greater detail below:
134 .Bd -literal
135 typedef struct _ftsent {
136         int fts_info;                   /* status for FTSENT structure */
137         char *fts_accpath;              /* access path */
138         char *fts_path;                 /* root path */
139         size_t fts_pathlen;             /* strlen(fts_path) */
140         char *fts_name;                 /* file name */
141         size_t fts_namelen;             /* strlen(fts_name) */
142         long fts_level;                 /* depth (\-1 to N) */
143         int fts_errno;                  /* file errno */
144         long long fts_number;           /* local numeric value */
145         void *fts_pointer;              /* local address value */
146         struct ftsent *fts_parent;      /* parent directory */
147         struct ftsent *fts_link;        /* next file structure */
148         struct ftsent *fts_cycle;       /* cycle structure */
149         struct stat *fts_statp;         /* stat(2) information */
150 } FTSENT;
151 .Ed
152 .Pp
153 These fields are defined as follows:
154 .Bl -tag -width "fts_namelen"
155 .It Fa fts_info
156 One of the following values describing the returned
157 .Vt FTSENT
158 structure and
159 the file it represents.
160 With the exception of directories without errors
161 .Pq Dv FTS_D ,
162 all of these
163 entries are terminal, that is, they will not be revisited, nor will any
164 of their descendants be visited.
165 .Bl  -tag -width FTS_DEFAULT
166 .It Dv FTS_D
167 A directory being visited in pre-order.
168 .It Dv FTS_DC
169 A directory that causes a cycle in the tree.
170 (The
171 .Fa fts_cycle
172 field of the
173 .Vt FTSENT
174 structure will be filled in as well.)
175 .It Dv FTS_DEFAULT
176 Any
177 .Vt FTSENT
178 structure that represents a file type not explicitly described
179 by one of the other
180 .Fa fts_info
181 values.
182 .It Dv FTS_DNR
183 A directory which cannot be read.
184 This is an error return, and the
185 .Fa fts_errno
186 field will be set to indicate what caused the error.
187 .It Dv FTS_DOT
188 A file named
189 .Ql .\&
190 or
191 .Ql ..\&
192 which was not specified as a file name to
193 .Fn fts_open
194 (see
195 .Dv FTS_SEEDOT ) .
196 .It Dv FTS_DP
197 A directory being visited in post-order.
198 The contents of the
199 .Vt FTSENT
200 structure will be unchanged from when
201 the directory was visited in pre-order, except for the
202 .Fa fts_info
203 field.
204 .It Dv FTS_ERR
205 This is an error return, and the
206 .Fa fts_errno
207 field will be set to indicate what caused the error.
208 .It Dv FTS_F
209 A regular file.
210 .It Dv FTS_NS
211 A file for which no
212 .Xr stat 2
213 information was available.
214 The contents of the
215 .Fa fts_statp
216 field are undefined.
217 This is an error return, and the
218 .Fa fts_errno
219 field will be set to indicate what caused the error.
220 .It Dv FTS_NSOK
221 A file for which no
222 .Xr stat 2
223 information was requested.
224 The contents of the
225 .Fa fts_statp
226 field are undefined.
227 .It Dv FTS_SL
228 A symbolic link.
229 .It Dv FTS_SLNONE
230 A symbolic link with a non-existent target.
231 The contents of the
232 .Fa fts_statp
233 field reference the file characteristic information for the symbolic link
234 itself.
235 .El
236 .It Fa fts_accpath
237 A path for accessing the file from the current directory.
238 .It Fa fts_path
239 The path for the file relative to the root of the traversal.
240 This path contains the path specified to
241 .Fn fts_open
242 as a prefix.
243 .It Fa fts_pathlen
244 The length of the string referenced by
245 .Fa fts_path .
246 .It Fa fts_name
247 The name of the file.
248 .It Fa fts_namelen
249 The length of the string referenced by
250 .Fa fts_name .
251 .It Fa fts_level
252 The depth of the traversal, numbered from \-1 to N, where this file
253 was found.
254 The
255 .Vt FTSENT
256 structure representing the parent of the starting point (or root)
257 of the traversal is numbered
258 .Dv FTS_ROOTPARENTLEVEL
259 (\-1), and the
260 .Vt FTSENT
261 structure for the root
262 itself is numbered
263 .Dv FTS_ROOTLEVEL
264 (0).
265 .It Fa fts_errno
266 Upon return of a
267 .Vt FTSENT
268 structure from the
269 .Fn fts_children
270 or
271 .Fn fts_read
272 functions, with its
273 .Fa fts_info
274 field set to
275 .Dv FTS_DNR ,
276 .Dv FTS_ERR
277 or
278 .Dv FTS_NS ,
279 the
280 .Fa fts_errno
281 field contains the value of the external variable
282 .Va errno
283 specifying the cause of the error.
284 Otherwise, the contents of the
285 .Fa fts_errno
286 field are undefined.
287 .It Fa fts_number
288 This field is provided for the use of the application program and is
289 not modified by the
290 .Nm
291 functions.
292 It is initialized to 0.
293 .It Fa fts_pointer
294 This field is provided for the use of the application program and is
295 not modified by the
296 .Nm
297 functions.
298 It is initialized to
299 .Dv NULL .
300 .It Fa fts_parent
301 A pointer to the
302 .Vt FTSENT
303 structure referencing the file in the hierarchy
304 immediately above the current file, i.e., the directory of which this
305 file is a member.
306 A parent structure for the initial entry point is provided as well,
307 however, only the
308 .Fa fts_level ,
309 .Fa fts_bignum ,
310 .Fa fts_number
311 and
312 .Fa fts_pointer
313 fields are guaranteed to be initialized.
314 .It Fa fts_link
315 Upon return from the
316 .Fn fts_children
317 function, the
318 .Fa fts_link
319 field points to the next structure in the NULL-terminated linked list of
320 directory members.
321 Otherwise, the contents of the
322 .Fa fts_link
323 field are undefined.
324 .It Fa fts_cycle
325 If a directory causes a cycle in the hierarchy (see
326 .Dv FTS_DC ) ,
327 either because
328 of a hard link between two directories, or a symbolic link pointing to a
329 directory, the
330 .Fa fts_cycle
331 field of the structure will point to the
332 .Vt FTSENT
333 structure in the hierarchy that references the same file as the current
334 .Vt FTSENT
335 structure.
336 Otherwise, the contents of the
337 .Fa fts_cycle
338 field are undefined.
339 .It Fa fts_statp
340 A pointer to
341 .Xr stat 2
342 information for the file.
343 .El
344 .Pp
345 A single buffer is used for all of the paths of all of the files in the
346 file hierarchy.
347 Therefore, the
348 .Fa fts_path
349 and
350 .Fa fts_accpath
351 fields are guaranteed to be
352 .Dv NUL Ns -terminated
353 .Em only
354 for the file most recently returned by
355 .Fn fts_read .
356 To use these fields to reference any files represented by other
357 .Vt FTSENT
358 structures will require that the path buffer be modified using the
359 information contained in that
360 .Vt FTSENT
361 structure's
362 .Fa fts_pathlen
363 field.
364 Any such modifications should be undone before further calls to
365 .Fn fts_read
366 are attempted.
367 The
368 .Fa fts_name
369 field is always
370 .Dv NUL Ns -terminated .
371 .Pp
372 Note that the use of
373 .Fa fts_bignum
374 is mutually exclusive with the use of
375 .Fa fts_number
376 or
377 .Fa fts_pointer .
378 .Sh FTS_OPEN
379 The
380 .Fn fts_open
381 function takes a pointer to an array of character pointers naming one
382 or more paths which make up a logical file hierarchy to be traversed.
383 The array must be terminated by a
384 .Dv NULL
385 pointer.
386 .Pp
387 There are
388 a number of options, at least one of which (either
389 .Dv FTS_LOGICAL
390 or
391 .Dv FTS_PHYSICAL )
392 must be specified.
393 The options are selected by
394 .Em or Ns 'ing
395 the following values:
396 .Bl -tag -width "FTS_PHYSICAL"
397 .It Dv FTS_COMFOLLOW
398 This option causes any symbolic link specified as a root path to be
399 followed immediately whether or not
400 .Dv FTS_LOGICAL
401 is also specified.
402 .It Dv FTS_LOGICAL
403 This option causes the
404 .Nm
405 routines to return
406 .Vt FTSENT
407 structures for the targets of symbolic links
408 instead of the symbolic links themselves.
409 If this option is set, the only symbolic links for which
410 .Vt FTSENT
411 structures
412 are returned to the application are those referencing non-existent files.
413 Either
414 .Dv FTS_LOGICAL
415 or
416 .Dv FTS_PHYSICAL
417 .Em must
418 be provided to the
419 .Fn fts_open
420 function.
421 .It Dv FTS_NOCHDIR
422 To allow descending to arbitrary depths
423 (independent of
424 .Brq Dv PATH_MAX )
425 and improve performance, the
426 .Nm
427 functions change directories as they walk the file hierarchy.
428 This has the side-effect that an application cannot rely on being
429 in any particular directory during the traversal.
430 The
431 .Dv FTS_NOCHDIR
432 option turns off this feature, and the
433 .Nm
434 functions will not change the current directory.
435 Note that applications should not themselves change their current directory
436 and try to access files unless
437 .Dv FTS_NOCHDIR
438 is specified and absolute
439 pathnames were provided as arguments to
440 .Fn fts_open .
441 .It Dv FTS_NOSTAT
442 By default, returned
443 .Vt FTSENT
444 structures reference file characteristic information (the
445 .Fa statp
446 field) for each file visited.
447 This option relaxes that requirement as a performance optimization,
448 allowing the
449 .Nm
450 functions to set the
451 .Fa fts_info
452 field to
453 .Dv FTS_NSOK
454 and leave the contents of the
455 .Fa statp
456 field undefined.
457 .It Dv FTS_PHYSICAL
458 This option causes the
459 .Nm
460 routines to return
461 .Vt FTSENT
462 structures for symbolic links themselves instead
463 of the target files they point to.
464 If this option is set,
465 .Vt FTSENT
466 structures for all symbolic links in the
467 hierarchy are returned to the application.
468 Either
469 .Dv FTS_LOGICAL
470 or
471 .Dv FTS_PHYSICAL
472 .Em must
473 be provided to the
474 .Fn fts_open
475 function.
476 .It Dv FTS_SEEDOT
477 By default, unless they are specified as path arguments to
478 .Fn fts_open ,
479 any files named
480 .Ql .\&
481 or
482 .Ql ..\&
483 encountered in the file hierarchy are ignored.
484 This option causes the
485 .Nm
486 routines to return
487 .Vt FTSENT
488 structures for them.
489 .It Dv FTS_XDEV
490 This option prevents
491 .Nm
492 from descending into directories that have a different device number
493 than the file from which the descent began.
494 .El
495 .Pp
496 The argument
497 .Fn compar
498 specifies a user-defined function which may be used to order the traversal
499 of the hierarchy.
500 It
501 takes two pointers to pointers to
502 .Vt FTSENT
503 structures as arguments and
504 should return a negative value, zero, or a positive value to indicate
505 if the file referenced by its first argument comes before, in any order
506 with respect to, or after, the file referenced by its second argument.
507 The
508 .Fa fts_accpath ,
509 .Fa fts_path
510 and
511 .Fa fts_pathlen
512 fields of the
513 .Vt FTSENT
514 structures may
515 .Em never
516 be used in this comparison.
517 If the
518 .Fa fts_info
519 field is set to
520 .Dv FTS_NS
521 or
522 .Dv FTS_NSOK ,
523 the
524 .Fa fts_statp
525 field may not either.
526 If the
527 .Fn compar
528 argument is
529 .Dv NULL ,
530 the directory traversal order is in the order listed in
531 .Fa path_argv
532 for the root paths, and in the order listed in the directory for
533 everything else.
534 .Sh FTS_READ
535 The
536 .Fn fts_read
537 function returns a pointer to an
538 .Vt FTSENT
539 structure describing a file in
540 the hierarchy.
541 Directories (that are readable and do not cause cycles) are visited at
542 least twice, once in pre-order and once in post-order.
543 All other files are visited at least once.
544 (Hard links between directories that do not cause cycles or symbolic
545 links to symbolic links may cause files to be visited more than once,
546 or directories more than twice.)
547 .Pp
548 If all the members of the hierarchy have been returned,
549 .Fn fts_read
550 returns
551 .Dv NULL
552 and sets the external variable
553 .Va errno
554 to 0.
555 If an error unrelated to a file in the hierarchy occurs,
556 .Fn fts_read
557 returns
558 .Dv NULL
559 and sets
560 .Va errno
561 appropriately.
562 If an error related to a returned file occurs, a pointer to an
563 .Vt FTSENT
564 structure is returned, and
565 .Va errno
566 may or may not have been set (see
567 .Fa fts_info ) .
568 .Pp
569 The
570 .Vt FTSENT
571 structures returned by
572 .Fn fts_read
573 may be overwritten after a call to
574 .Fn fts_close
575 on the same file hierarchy stream, or, after a call to
576 .Fn fts_read
577 on the same file hierarchy stream unless they represent a file of type
578 directory, in which case they will not be overwritten until after a call to
579 .Fn fts_read
580 after the
581 .Vt FTSENT
582 structure has been returned by the function
583 .Fn fts_read
584 in post-order.
585 .Sh FTS_CHILDREN
586 The
587 .Fn fts_children
588 function returns a pointer to an
589 .Vt FTSENT
590 structure describing the first entry in a NULL-terminated linked list of
591 the files in the directory represented by the
592 .Vt FTSENT
593 structure most recently returned by
594 .Fn fts_read .
595 The list is linked through the
596 .Fa fts_link
597 field of the
598 .Vt FTSENT
599 structure, and is ordered by the user-specified comparison function, if any.
600 Repeated calls to
601 .Fn fts_children
602 will recreate this linked list.
603 .Pp
604 As a special case, if
605 .Fn fts_read
606 has not yet been called for a hierarchy,
607 .Fn fts_children
608 will return a pointer to the files in the logical directory specified to
609 .Fn fts_open ,
610 i.e., the arguments specified to
611 .Fn fts_open .
612 Otherwise, if the
613 .Vt FTSENT
614 structure most recently returned by
615 .Fn fts_read
616 is not a directory being visited in pre-order,
617 or the directory does not contain any files,
618 .Fn fts_children
619 returns
620 .Dv NULL
621 and sets
622 .Va errno
623 to zero.
624 If an error occurs,
625 .Fn fts_children
626 returns
627 .Dv NULL
628 and sets
629 .Va errno
630 appropriately.
631 .Pp
632 The
633 .Vt FTSENT
634 structures returned by
635 .Fn fts_children
636 may be overwritten after a call to
637 .Fn fts_children ,
638 .Fn fts_close
639 or
640 .Fn fts_read
641 on the same file hierarchy stream.
642 .Pp
643 .Em Option
644 may be set to the following value:
645 .Bl -tag -width FTS_NAMEONLY
646 .It Dv FTS_NAMEONLY
647 Only the names of the files are needed.
648 The contents of all the fields in the returned linked list of structures
649 are undefined with the exception of the
650 .Fa fts_name
651 and
652 .Fa fts_namelen
653 fields.
654 .El
655 .Sh FTS_SET
656 The function
657 .Fn fts_set
658 allows the user application to determine further processing for the
659 file
660 .Fa f
661 of the stream
662 .Fa ftsp .
663 The
664 .Fn fts_set
665 function
666 returns 0 on success, and \-1 if an error occurs.
667 .Em Option
668 must be set to one of the following values:
669 .Bl -tag -width FTS_PHYSICAL
670 .It Dv FTS_AGAIN
671 Re-visit the file; any file type may be re-visited.
672 The next call to
673 .Fn fts_read
674 will return the referenced file.
675 The
676 .Fa fts_stat
677 and
678 .Fa fts_info
679 fields of the structure will be reinitialized at that time,
680 but no other fields will have been changed.
681 This option is meaningful only for the most recently returned
682 file from
683 .Fn fts_read .
684 Normal use is for post-order directory visits, where it causes the
685 directory to be re-visited (in both pre and post-order) as well as all
686 of its descendants.
687 .It Dv FTS_FOLLOW
688 The referenced file must be a symbolic link.
689 If the referenced file is the one most recently returned by
690 .Fn fts_read ,
691 the next call to
692 .Fn fts_read
693 returns the file with the
694 .Fa fts_info
695 and
696 .Fa fts_statp
697 fields reinitialized to reflect the target of the symbolic link instead
698 of the symbolic link itself.
699 If the file is one of those most recently returned by
700 .Fn fts_children ,
701 the
702 .Fa fts_info
703 and
704 .Fa fts_statp
705 fields of the structure, when returned by
706 .Fn fts_read ,
707 will reflect the target of the symbolic link instead of the symbolic link
708 itself.
709 In either case, if the target of the symbolic link does not exist the
710 fields of the returned structure will be unchanged and the
711 .Fa fts_info
712 field will be set to
713 .Dv FTS_SLNONE .
714 .Pp
715 If the target of the link is a directory, the pre-order return, followed
716 by the return of all of its descendants, followed by a post-order return,
717 is done.
718 .It Dv FTS_SKIP
719 No descendants of this file are visited.
720 The file may be one of those most recently returned by either
721 .Fn fts_children
722 or
723 .Fn fts_read .
724 .El
725 .Sh FTS_CLOSE
726 The
727 .Fn fts_close
728 function closes a file hierarchy stream
729 .Fa ftsp
730 and restores the current directory to the directory from which
731 .Fn fts_open
732 was called to open
733 .Fa ftsp .
734 The
735 .Fn fts_close
736 function
737 returns 0 on success, and \-1 if an error occurs.
738 .Sh ERRORS
739 The function
740 .Fn fts_open
741 may fail and set
742 .Va errno
743 for any of the errors specified for the library functions
744 .Xr open 2
745 and
746 .Xr malloc 3 .
747 .Pp
748 The function
749 .Fn fts_close
750 may fail and set
751 .Va errno
752 for any of the errors specified for the library functions
753 .Xr chdir 2
754 and
755 .Xr close 2 .
756 .Pp
757 The functions
758 .Fn fts_read
759 and
760 .Fn fts_children
761 may fail and set
762 .Va errno
763 for any of the errors specified for the library functions
764 .Xr chdir 2 ,
765 .Xr malloc 3 ,
766 .Xr opendir 3 ,
767 .Xr readdir 3
768 and
769 .Xr stat 2 .
770 .Pp
771 In addition,
772 .Fn fts_children ,
773 .Fn fts_open
774 and
775 .Fn fts_set
776 may fail and set
777 .Va errno
778 as follows:
779 .Bl -tag -width Er
780 .It Bq Er EINVAL
781 The options were invalid, or the list were empty.
782 .El
783 .Sh SEE ALSO
784 .Xr find 1 ,
785 .Xr chdir 2 ,
786 .Xr stat 2 ,
787 .Xr ftw 3 ,
788 .Xr qsort 3
789 .Sh HISTORY
790 The
791 .Nm
792 interface was first introduced in
793 .Bx 4.4 .
794 The
795 .Fn fts_get_clientptr ,
796 .Fn fts_get_stream ,
797 and
798 .Fn fts_set_clientptr
799 functions were introduced in
800 .Fx 5.0 ,
801 principally to provide for alternative interfaces to the
802 .Nm
803 functionality using different data structures.
804 .Sh BUGS
805 The
806 .Fn fts_open
807 function will automatically set the
808 .Dv FTS_NOCHDIR
809 option if the
810 .Dv FTS_LOGICAL
811 option is provided, or if it cannot
812 .Xr open 2
813 the current directory.