fts(3) Library Functions Manual fts(3) fts fts_open fts_read fts_children fts_set fts_close - (libc -lc) #include #include #include FTS *fts_open(char *const *path_argv, int options, typeof(int (const FTSENT **, const FTSENT **)) *_Nullable compar); FTSENT *fts_read(FTS *ftsp); FTSENT *fts_children(FTS *ftsp, int instr); int fts_set(FTS *ftsp, FTSENT *f, int instr); int fts_close(FTS *ftsp); fts . fts_open() "" ( FTS *) "" . fts . fts_read() . fts_children() . ( ) ( ). . "" ( ) ( ) / . ( ) . FTS . FTSENT . FTSENT . "" " FTSENT" . FTSENT . ( ): typedef struct _ftsent { unsigned short fts_info; /* FTSENT */ char *fts_accpath; /* */ char *fts_path; /* */ short fts_pathlen; /* strlen(fts_path) + strlen(fts_name) */ char *fts_name; /* */ short fts_namelen; /* strlen(fts_name) */ short fts_level; /* ( -1 N) */ int fts_errno; /* (errno) */ long fts_number; /* */ void *fts_pointer; /* */ struct _ftsent *fts_parent; /* */ struct _ftsent *fts_link; /* */ struct _ftsent *fts_cycle; /* */ struct stat *fts_statp; /* [l]stat(2) */ } FTSENT; : fts_info FTSENT . (FTS_D) . FTS_D . FTS_DC . ( fts_cycle FTSENT .) FTS_DEFAULT FTSENT fts_info . FTS_DNR . fts_errno . FTS_DOT "." ".." fts_open() ( FTS_SEEDOT). FTS_DP . FTSENT fts_info FTS_D. FTS_ERR fts_errno . FTS_F . FTS_NS [l]stat(2) . fts_statp . fts_errno . FTS_NSOK [l]stat(2) . fts_statp . FTS_SL . FTS_SLNONE . fts_statp . fts_accpath . fts_path . fts_open() . fts_pathlen fts_path fts_name. fts_name . fts_namelen fts_name. fts_level -1 N . FTSENT ( ) -1 FTSENT 0. fts_errno fts_children() fts_read() FTSENT fts_info FTS_DNR FTS_ERR FTS_NS fts_errno ( errno) . fts_errno . fts_number fts. 0. fts_pointer fts. NULL. fts_parent FTSENT . fts_level fts_number fts_pointer . fts_link fts_children() fts_link NULL . fts_link . fts_cycle ( FTS_DC) fts_cycle FTSENT FTSENT . fts_cycle . fts_statp [l]stat(2) . . fts_path fts_accpath fts_read(). FTSENT fts_pathlen FTSENT. fts_read(). fts_name . fts_open() fts_open() . . ( FTS_LOGICAL FTS_PHYSICAL). OR : FTS_LOGICAL fts FTSENT . FTSENT : fts_statp stat(2) lstat(2). FTS_PHYSICAL fts FTSENT . FTSENT : fts_statp lstat(2). FTS_COMFOLLOW FTS_LOGICAL . FTS_NOCHDIR fts . . fts . FTS_NOCHDIR fts_open(). FTS_NOSTAT FTSENT ( fts_statp) . fts fts_info FTS_NSOK fts_statp . FTS_SEEDOT fts_open() "." ".." . fts FTSENT . FTS_XDEV fts . compar() . FTSENT . fts_accpath fts_path fts_pathlen FTSENT . fts_info FTS_NS FTS_NSOK fts_statp. compar() NULL path_argv . fts_read() fts_read() FTSENT . ( ) . . ( .) fts_read() NULL errno 0. fts_read() NULL errno . FTSENT errno ( fts_info). FTSENT fts_read() fts_close() fts_read() fts_read() FTSENT fts_read() . fts_children() fts_children() FTSENT NULL FTSENT fts_read(). fts_link FTSENT . fts_children() . fts_read() fts_children() fts_open() fts_open(). FTSENT fts_read() fts_children() NULL errno . fts_children() NULL errno . FTSENT fts_children() fts_children() fts_close() fts_read() . instr : FTS_NAMEONLY . fts_name fts_namelen. fts_set() fts_set() f ftsp. fts_set() 0 -1 . instr 0 ( " ") : FTS_AGAIN . fts_read() . fts_stat fts_info . fts_read(). ( ) . FTS_FOLLOW . fts_read() fts_read() fts_info fts_statp . fts_children() fts_info fts_statp fts_read() . fts_info FTS_SLNONE. . FTS_SKIP . fts_children() fts_read(). fts_close() fts_close() ftsp fts_open() ftsp. fts_close() 0 -1 . fts_open() errno open(2) malloc(3). fts_open() errno : ENOENT path_argv . fts_close() errno chdir(2) close(2). fts_read() fts_children() errno chdir(2) malloc(3) opendir(3) readdir(3) [l]stat(2). fts_children() fts_open() fts_set() errno : EINVAL options instr . attributes(7). +----------------------+------------------------------------+--------------------------------------------------------------------+ | | | | +----------------------+------------------------------------+--------------------------------------------------------------------+ |fts_open(), | | MT-Safe | |fts_set(), | | | |fts_close() | | | +----------------------+------------------------------------+--------------------------------------------------------------------+ |fts_read(), | | (MT-Unsafe) | |fts_children() | | | +----------------------+------------------------------------+--------------------------------------------------------------------+ . glibc 2. 4.4BSD. glibc 2.23 LFS ( -D_FILE_OFFSET_BITS=64). find(1) chdir(2) lstat(2) stat(2) ftw(3) qsort(3) 3 . . : . 6.18 21 2025 fts(3)