1 /* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)fts.h 8.3 (Berkeley) 08/14/94 8 */ 9 10 #ifndef _FTS_H_ 11 #define _FTS_H_ 12 13 typedef struct { 14 struct _ftsent *fts_cur; /* current node */ 15 struct _ftsent *fts_child; /* linked list of children */ 16 struct _ftsent **fts_array; /* sort array */ 17 dev_t fts_dev; /* starting device # */ 18 char *fts_path; /* path for this descent */ 19 int fts_rfd; /* fd for root */ 20 int fts_pathlen; /* sizeof(path) */ 21 int fts_nitems; /* elements in the sort array */ 22 int (*fts_compar)(); /* compare function */ 23 24 #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ 25 #define FTS_LOGICAL 0x002 /* logical walk */ 26 #define FTS_NOCHDIR 0x004 /* don't change directories */ 27 #define FTS_NOSTAT 0x008 /* don't get stat info */ 28 #define FTS_PHYSICAL 0x010 /* physical walk */ 29 #define FTS_SEEDOT 0x020 /* return dot and dot-dot */ 30 #define FTS_XDEV 0x040 /* don't cross devices */ 31 #define FTS_WHITEOUT 0x080 /* return whiteout information */ 32 #define FTS_OPTIONMASK 0x0ff /* valid user option mask */ 33 34 #define FTS_NAMEONLY 0x100 /* (private) child names only */ 35 #define FTS_STOP 0x200 /* (private) unrecoverable error */ 36 int fts_options; /* fts_open options, global flags */ 37 } FTS; 38 39 typedef struct _ftsent { 40 struct _ftsent *fts_cycle; /* cycle node */ 41 struct _ftsent *fts_parent; /* parent directory */ 42 struct _ftsent *fts_link; /* next file in directory */ 43 long fts_number; /* local numeric value */ 44 void *fts_pointer; /* local address value */ 45 char *fts_accpath; /* access path */ 46 char *fts_path; /* root path */ 47 int fts_errno; /* errno for this node */ 48 int fts_symfd; /* fd for symlink */ 49 u_short fts_pathlen; /* strlen(fts_path) */ 50 u_short fts_namelen; /* strlen(fts_name) */ 51 52 ino_t fts_ino; /* inode */ 53 dev_t fts_dev; /* device */ 54 nlink_t fts_nlink; /* link count */ 55 56 #define FTS_ROOTPARENTLEVEL -1 57 #define FTS_ROOTLEVEL 0 58 short fts_level; /* depth (-1 to N) */ 59 60 #define FTS_D 1 /* preorder directory */ 61 #define FTS_DC 2 /* directory that causes cycles */ 62 #define FTS_DEFAULT 3 /* none of the above */ 63 #define FTS_DNR 4 /* unreadable directory */ 64 #define FTS_DOT 5 /* dot or dot-dot */ 65 #define FTS_DP 6 /* postorder directory */ 66 #define FTS_ERR 7 /* error; errno is set */ 67 #define FTS_F 8 /* regular file */ 68 #define FTS_INIT 9 /* initialized only */ 69 #define FTS_NS 10 /* stat(2) failed */ 70 #define FTS_NSOK 11 /* no stat(2) requested */ 71 #define FTS_SL 12 /* symbolic link */ 72 #define FTS_SLNONE 13 /* symbolic link without target */ 73 #define FTS_W 14 /* whiteout object */ 74 u_short fts_info; /* user flags for FTSENT structure */ 75 76 #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 77 #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 78 #define FTS_ISW 0x04 /* this is a whiteout object */ 79 u_short fts_flags; /* private flags for FTSENT structure */ 80 81 #define FTS_AGAIN 1 /* read node again */ 82 #define FTS_FOLLOW 2 /* follow symbolic link */ 83 #define FTS_NOINSTR 3 /* no instructions */ 84 #define FTS_SKIP 4 /* discard node */ 85 u_short fts_instr; /* fts_set() instructions */ 86 87 struct stat *fts_statp; /* stat(2) information */ 88 char fts_name[1]; /* file name */ 89 } FTSENT; 90 91 #include <sys/cdefs.h> 92 93 __BEGIN_DECLS 94 FTSENT *fts_children __P((FTS *, int)); 95 int fts_close __P((FTS *)); 96 FTS *fts_open __P((char * const *, int, 97 int (*)(const FTSENT **, const FTSENT **))); 98 FTSENT *fts_read __P((FTS *)); 99 int fts_set __P((FTS *, FTSENT *, int)); 100 __END_DECLS 101 102 #endif /* !_FTS_H_ */ 103