11539Srgrimes/* 21539Srgrimes * Copyright (c) 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 13203964Simp * 3. Neither the name of the University nor the names of its contributors 141539Srgrimes * may be used to endorse or promote products derived from this software 151539Srgrimes * without specific prior written permission. 161539Srgrimes * 171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271539Srgrimes * SUCH DAMAGE. 281539Srgrimes * 2923650Speter * @(#)fts.h 8.3 (Berkeley) 8/14/94 3078169Sru * $FreeBSD$ 311539Srgrimes */ 321539Srgrimes 331539Srgrimes#ifndef _FTS_H_ 341539Srgrimes#define _FTS_H_ 351539Srgrimes 36250887Sed#include <sys/_types.h> 37250887Sed 381539Srgrimestypedef struct { 391539Srgrimes struct _ftsent *fts_cur; /* current node */ 401539Srgrimes struct _ftsent *fts_child; /* linked list of children */ 411539Srgrimes struct _ftsent **fts_array; /* sort array */ 42250887Sed __dev_t fts_dev; /* starting device # */ 431539Srgrimes char *fts_path; /* path for this descent */ 441539Srgrimes int fts_rfd; /* fd for root */ 45250887Sed __size_t fts_pathlen; /* sizeof(path) */ 46250887Sed __size_t fts_nitems; /* elements in the sort array */ 4778169Sru int (*fts_compar) /* compare function */ 48103726Swollman (const struct _ftsent * const *, const struct _ftsent * const *); 491539Srgrimes 501539Srgrimes#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ 511539Srgrimes#define FTS_LOGICAL 0x002 /* logical walk */ 521539Srgrimes#define FTS_NOCHDIR 0x004 /* don't change directories */ 531539Srgrimes#define FTS_NOSTAT 0x008 /* don't get stat info */ 541539Srgrimes#define FTS_PHYSICAL 0x010 /* physical walk */ 551539Srgrimes#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ 561539Srgrimes#define FTS_XDEV 0x040 /* don't cross devices */ 5723650Speter#define FTS_WHITEOUT 0x080 /* return whiteout information */ 5823650Speter#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ 591539Srgrimes 6023650Speter#define FTS_NAMEONLY 0x100 /* (private) child names only */ 6123650Speter#define FTS_STOP 0x200 /* (private) unrecoverable error */ 621539Srgrimes int fts_options; /* fts_open options, global flags */ 63103726Swollman void *fts_clientptr; /* thunk for sort function */ 641539Srgrimes} FTS; 651539Srgrimes 661539Srgrimestypedef struct _ftsent { 671539Srgrimes struct _ftsent *fts_cycle; /* cycle node */ 681539Srgrimes struct _ftsent *fts_parent; /* parent directory */ 691539Srgrimes struct _ftsent *fts_link; /* next file in directory */ 70175688Syar long long fts_number; /* local numeric value */ 71175688Syar#define fts_bignum fts_number /* XXX non-std, should go away */ 72175688Syar void *fts_pointer; /* local address value */ 731539Srgrimes char *fts_accpath; /* access path */ 741539Srgrimes char *fts_path; /* root path */ 751539Srgrimes int fts_errno; /* errno for this node */ 761539Srgrimes int fts_symfd; /* fd for symlink */ 77250887Sed __size_t fts_pathlen; /* strlen(fts_path) */ 78250887Sed __size_t fts_namelen; /* strlen(fts_name) */ 791539Srgrimes 80250887Sed __ino_t fts_ino; /* inode */ 81250887Sed __dev_t fts_dev; /* device */ 82250887Sed __nlink_t fts_nlink; /* link count */ 831539Srgrimes 841539Srgrimes#define FTS_ROOTPARENTLEVEL -1 851539Srgrimes#define FTS_ROOTLEVEL 0 86175688Syar long fts_level; /* depth (-1 to N) */ 871539Srgrimes 881539Srgrimes#define FTS_D 1 /* preorder directory */ 891539Srgrimes#define FTS_DC 2 /* directory that causes cycles */ 901539Srgrimes#define FTS_DEFAULT 3 /* none of the above */ 911539Srgrimes#define FTS_DNR 4 /* unreadable directory */ 921539Srgrimes#define FTS_DOT 5 /* dot or dot-dot */ 931539Srgrimes#define FTS_DP 6 /* postorder directory */ 941539Srgrimes#define FTS_ERR 7 /* error; errno is set */ 951539Srgrimes#define FTS_F 8 /* regular file */ 961539Srgrimes#define FTS_INIT 9 /* initialized only */ 971539Srgrimes#define FTS_NS 10 /* stat(2) failed */ 981539Srgrimes#define FTS_NSOK 11 /* no stat(2) requested */ 991539Srgrimes#define FTS_SL 12 /* symbolic link */ 1001539Srgrimes#define FTS_SLNONE 13 /* symbolic link without target */ 10123650Speter#define FTS_W 14 /* whiteout object */ 102175688Syar int fts_info; /* user status for FTSENT structure */ 1031539Srgrimes 1041539Srgrimes#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 1051539Srgrimes#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 10623650Speter#define FTS_ISW 0x04 /* this is a whiteout object */ 107175688Syar unsigned fts_flags; /* private flags for FTSENT structure */ 1081539Srgrimes 1091539Srgrimes#define FTS_AGAIN 1 /* read node again */ 1101539Srgrimes#define FTS_FOLLOW 2 /* follow symbolic link */ 1111539Srgrimes#define FTS_NOINSTR 3 /* no instructions */ 1121539Srgrimes#define FTS_SKIP 4 /* discard node */ 113175688Syar int fts_instr; /* fts_set() instructions */ 1141539Srgrimes 1151539Srgrimes struct stat *fts_statp; /* stat(2) information */ 116103726Swollman char *fts_name; /* file name */ 117103726Swollman FTS *fts_fts; /* back pointer to main FTS */ 1181539Srgrimes} FTSENT; 1191539Srgrimes 1201539Srgrimes#include <sys/cdefs.h> 1211539Srgrimes 1221539Srgrimes__BEGIN_DECLS 12393032SimpFTSENT *fts_children(FTS *, int); 12493032Simpint fts_close(FTS *); 125103726Swollmanvoid *fts_get_clientptr(FTS *); 126103726Swollman#define fts_get_clientptr(fts) ((fts)->fts_clientptr) 127103726SwollmanFTS *fts_get_stream(FTSENT *); 128103726Swollman#define fts_get_stream(ftsent) ((ftsent)->fts_fts) 12993032SimpFTS *fts_open(char * const *, int, 130103726Swollman int (*)(const FTSENT * const *, const FTSENT * const *)); 13193032SimpFTSENT *fts_read(FTS *); 13293032Simpint fts_set(FTS *, FTSENT *, int); 133103726Swollmanvoid fts_set_clientptr(FTS *, void *); 1341539Srgrimes__END_DECLS 1351539Srgrimes 1361539Srgrimes#endif /* !_FTS_H_ */ 137