1*2fe8fb19SBen Gras /* $NetBSD: fts.h,v 1.19 2009/08/16 19:33:38 christos Exp $ */ 2*2fe8fb19SBen Gras 3e0483258SBen Gras /* 4e0483258SBen Gras * Copyright (c) 1989, 1993 5e0483258SBen Gras * The Regents of the University of California. All rights reserved. 6e0483258SBen Gras * 7e0483258SBen Gras * Redistribution and use in source and binary forms, with or without 8e0483258SBen Gras * modification, are permitted provided that the following conditions 9e0483258SBen Gras * are met: 10e0483258SBen Gras * 1. Redistributions of source code must retain the above copyright 11e0483258SBen Gras * notice, this list of conditions and the following disclaimer. 12e0483258SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 13e0483258SBen Gras * notice, this list of conditions and the following disclaimer in the 14e0483258SBen Gras * documentation and/or other materials provided with the distribution. 15*2fe8fb19SBen Gras * 3. Neither the name of the University nor the names of its contributors 16e0483258SBen Gras * may be used to endorse or promote products derived from this software 17e0483258SBen Gras * without specific prior written permission. 18e0483258SBen Gras * 19e0483258SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20e0483258SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21e0483258SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22e0483258SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23e0483258SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24e0483258SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25e0483258SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26e0483258SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27e0483258SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28e0483258SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29e0483258SBen Gras * SUCH DAMAGE. 30e0483258SBen Gras * 31e0483258SBen Gras * @(#)fts.h 8.3 (Berkeley) 8/14/94 32e0483258SBen Gras */ 33e0483258SBen Gras 34e0483258SBen Gras #ifndef _FTS_H_ 35e0483258SBen Gras #define _FTS_H_ 36e0483258SBen Gras 37*2fe8fb19SBen Gras #ifndef __fts_stat_t 38*2fe8fb19SBen Gras #define __fts_stat_t struct stat 39*2fe8fb19SBen Gras #endif 40*2fe8fb19SBen Gras #ifndef __fts_nlink_t 41*2fe8fb19SBen Gras #define __fts_nlink_t nlink_t 42*2fe8fb19SBen Gras #endif 43*2fe8fb19SBen Gras #ifndef __fts_ino_t 44*2fe8fb19SBen Gras #define __fts_ino_t ino_t 45*2fe8fb19SBen Gras #endif 46*2fe8fb19SBen Gras #ifndef __fts_length_t 47*2fe8fb19SBen Gras #define __fts_length_t unsigned int 48*2fe8fb19SBen Gras #endif 49*2fe8fb19SBen Gras #ifndef __fts_number_t 50*2fe8fb19SBen Gras #define __fts_number_t int64_t 51*2fe8fb19SBen Gras #endif 52*2fe8fb19SBen Gras #ifndef __fts_dev_t 53*2fe8fb19SBen Gras #define __fts_dev_t dev_t 54*2fe8fb19SBen Gras #endif 55*2fe8fb19SBen Gras #ifndef __fts_level_t 56*2fe8fb19SBen Gras #define __fts_level_t int 57*2fe8fb19SBen Gras #endif 58*2fe8fb19SBen Gras 59e0483258SBen Gras typedef struct { 60e0483258SBen Gras struct _ftsent *fts_cur; /* current node */ 61e0483258SBen Gras struct _ftsent *fts_child; /* linked list of children */ 62e0483258SBen Gras struct _ftsent **fts_array; /* sort array */ 63e0483258SBen Gras dev_t fts_dev; /* starting device # */ 64e0483258SBen Gras char *fts_path; /* path for this descent */ 65e0483258SBen Gras int fts_rfd; /* fd for root */ 66*2fe8fb19SBen Gras unsigned int fts_pathlen; /* sizeof(path) */ 67*2fe8fb19SBen Gras unsigned int fts_nitems; /* elements in the sort array */ 68e0483258SBen Gras int (*fts_compar) /* compare function */ 69*2fe8fb19SBen Gras (const struct _ftsent **, const struct _ftsent **); 70e0483258SBen Gras 71e0483258SBen Gras #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ 72e0483258SBen Gras #define FTS_LOGICAL 0x002 /* logical walk */ 73e0483258SBen Gras #define FTS_NOCHDIR 0x004 /* don't change directories */ 74e0483258SBen Gras #define FTS_NOSTAT 0x008 /* don't get stat info */ 75e0483258SBen Gras #define FTS_PHYSICAL 0x010 /* physical walk */ 76e0483258SBen Gras #define FTS_SEEDOT 0x020 /* return dot and dot-dot */ 77e0483258SBen Gras #define FTS_XDEV 0x040 /* don't cross devices */ 78*2fe8fb19SBen Gras #define FTS_WHITEOUT 0x080 /* return whiteout information */ 79e0483258SBen Gras #define FTS_OPTIONMASK 0x0ff /* valid user option mask */ 80e0483258SBen Gras 81e0483258SBen Gras #define FTS_NAMEONLY 0x100 /* (private) child names only */ 82e0483258SBen Gras #define FTS_STOP 0x200 /* (private) unrecoverable error */ 83e0483258SBen Gras int fts_options; /* fts_open options, global flags */ 84e0483258SBen Gras } FTS; 85e0483258SBen Gras 86e0483258SBen Gras typedef struct _ftsent { 87e0483258SBen Gras struct _ftsent *fts_cycle; /* cycle node */ 88e0483258SBen Gras struct _ftsent *fts_parent; /* parent directory */ 89e0483258SBen Gras struct _ftsent *fts_link; /* next file in directory */ 90*2fe8fb19SBen Gras __fts_number_t fts_number; /* local numeric value */ 91*2fe8fb19SBen Gras void *fts_pointer; /* local address value */ 92e0483258SBen Gras char *fts_accpath; /* access path */ 93e0483258SBen Gras char *fts_path; /* root path */ 94e0483258SBen Gras int fts_errno; /* errno for this node */ 95e0483258SBen Gras int fts_symfd; /* fd for symlink */ 96*2fe8fb19SBen Gras __fts_length_t fts_pathlen; /* strlen(fts_path) */ 97*2fe8fb19SBen Gras __fts_length_t fts_namelen; /* strlen(fts_name) */ 98e0483258SBen Gras 99*2fe8fb19SBen Gras __fts_ino_t fts_ino; /* inode */ 100*2fe8fb19SBen Gras __fts_dev_t fts_dev; /* device */ 101*2fe8fb19SBen Gras __fts_nlink_t fts_nlink; /* link count */ 102e0483258SBen Gras 103e0483258SBen Gras #define FTS_ROOTPARENTLEVEL -1 104e0483258SBen Gras #define FTS_ROOTLEVEL 0 105*2fe8fb19SBen Gras __fts_level_t fts_level; /* depth (-1 to N) */ 106e0483258SBen Gras 107e0483258SBen Gras #define FTS_D 1 /* preorder directory */ 108e0483258SBen Gras #define FTS_DC 2 /* directory that causes cycles */ 109e0483258SBen Gras #define FTS_DEFAULT 3 /* none of the above */ 110e0483258SBen Gras #define FTS_DNR 4 /* unreadable directory */ 111e0483258SBen Gras #define FTS_DOT 5 /* dot or dot-dot */ 112e0483258SBen Gras #define FTS_DP 6 /* postorder directory */ 113e0483258SBen Gras #define FTS_ERR 7 /* error; errno is set */ 114e0483258SBen Gras #define FTS_F 8 /* regular file */ 115e0483258SBen Gras #define FTS_INIT 9 /* initialized only */ 116e0483258SBen Gras #define FTS_NS 10 /* stat(2) failed */ 117e0483258SBen Gras #define FTS_NSOK 11 /* no stat(2) requested */ 118e0483258SBen Gras #define FTS_SL 12 /* symbolic link */ 119e0483258SBen Gras #define FTS_SLNONE 13 /* symbolic link without target */ 120e0483258SBen Gras #define FTS_W 14 /* whiteout object */ 121*2fe8fb19SBen Gras unsigned short fts_info; /* user flags for FTSENT structure */ 122e0483258SBen Gras 123e0483258SBen Gras #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 124e0483258SBen Gras #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 125e0483258SBen Gras #define FTS_ISW 0x04 /* this is a whiteout object */ 126*2fe8fb19SBen Gras unsigned short fts_flags; /* private flags for FTSENT structure */ 127e0483258SBen Gras 128e0483258SBen Gras #define FTS_AGAIN 1 /* read node again */ 129e0483258SBen Gras #define FTS_FOLLOW 2 /* follow symbolic link */ 130e0483258SBen Gras #define FTS_NOINSTR 3 /* no instructions */ 131e0483258SBen Gras #define FTS_SKIP 4 /* discard node */ 132*2fe8fb19SBen Gras unsigned short fts_instr; /* fts_set() instructions */ 133e0483258SBen Gras 134*2fe8fb19SBen Gras __fts_stat_t *fts_statp; /* stat(2) information */ 135*2fe8fb19SBen Gras char fts_name[1]; /* file name */ 136e0483258SBen Gras } FTSENT; 137e0483258SBen Gras 138*2fe8fb19SBen Gras #include <sys/cdefs.h> 139*2fe8fb19SBen Gras 140*2fe8fb19SBen Gras __BEGIN_DECLS 141*2fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__ 142*2fe8fb19SBen Gras FTSENT *fts_children(FTS *, int) __RENAME(__fts_children60); 143*2fe8fb19SBen Gras int fts_close(FTS *) __RENAME(__fts_close60); 144e0483258SBen Gras FTS *fts_open(char * const *, int, 145*2fe8fb19SBen Gras int (*)(const FTSENT **, const FTSENT **)) __RENAME(__fts_open60); 146*2fe8fb19SBen Gras FTSENT *fts_read(FTS *) __RENAME(__fts_read60); 147*2fe8fb19SBen Gras int fts_set(FTS *, FTSENT *, int) __RENAME(__fts_set60); 148*2fe8fb19SBen Gras #endif 149*2fe8fb19SBen Gras __END_DECLS 150e0483258SBen Gras 151e0483258SBen Gras #endif /* !_FTS_H_ */ 152