1*f2279759Schristos /* $NetBSD: fts.h,v 1.19 2009/08/16 19:33:38 christos Exp $ */ 24d2cbfceScgd 361f28255Scgd /* 4eeb91fe4Scgd * Copyright (c) 1989, 1993 5eeb91fe4Scgd * The Regents of the University of California. All rights reserved. 661f28255Scgd * 761f28255Scgd * Redistribution and use in source and binary forms, with or without 861f28255Scgd * modification, are permitted provided that the following conditions 961f28255Scgd * are met: 1061f28255Scgd * 1. Redistributions of source code must retain the above copyright 1161f28255Scgd * notice, this list of conditions and the following disclaimer. 1261f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1361f28255Scgd * notice, this list of conditions and the following disclaimer in the 1461f28255Scgd * documentation and/or other materials provided with the distribution. 15039cc956Sagc * 3. Neither the name of the University nor the names of its contributors 1661f28255Scgd * may be used to endorse or promote products derived from this software 1761f28255Scgd * without specific prior written permission. 1861f28255Scgd * 1961f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2061f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2161f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2261f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2361f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2461f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2561f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2661f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2761f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2861f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2961f28255Scgd * SUCH DAMAGE. 3061f28255Scgd * 3104ffeab7Smycroft * @(#)fts.h 8.3 (Berkeley) 8/14/94 3261f28255Scgd */ 3361f28255Scgd 3461f28255Scgd #ifndef _FTS_H_ 3561f28255Scgd #define _FTS_H_ 3661f28255Scgd 3733037645Schristos #ifndef __fts_stat_t 3833037645Schristos #define __fts_stat_t struct stat 3933037645Schristos #endif 4033037645Schristos #ifndef __fts_nlink_t 4133037645Schristos #define __fts_nlink_t nlink_t 4233037645Schristos #endif 4333037645Schristos #ifndef __fts_ino_t 4433037645Schristos #define __fts_ino_t ino_t 4533037645Schristos #endif 468d5214b1Schristos #ifndef __fts_length_t 47c293dd61Slukem #define __fts_length_t unsigned int 488d5214b1Schristos #endif 49a14221d5Schristos #ifndef __fts_number_t 50a14221d5Schristos #define __fts_number_t int64_t 51a14221d5Schristos #endif 5250728e78Schristos #ifndef __fts_dev_t 5350728e78Schristos #define __fts_dev_t dev_t 5450728e78Schristos #endif 55*f2279759Schristos #ifndef __fts_level_t 56*f2279759Schristos #define __fts_level_t int 57*f2279759Schristos #endif 5833037645Schristos 5921e1e24dSfvdl typedef struct { 6021e1e24dSfvdl struct _ftsent *fts_cur; /* current node */ 6121e1e24dSfvdl struct _ftsent *fts_child; /* linked list of children */ 6221e1e24dSfvdl struct _ftsent **fts_array; /* sort array */ 6321e1e24dSfvdl dev_t fts_dev; /* starting device # */ 6421e1e24dSfvdl char *fts_path; /* path for this descent */ 6521e1e24dSfvdl int fts_rfd; /* fd for root */ 66c293dd61Slukem unsigned int fts_pathlen; /* sizeof(path) */ 67c293dd61Slukem unsigned int fts_nitems; /* elements in the sort array */ 68d5838591Schristos int (*fts_compar) /* compare function */ 6919b7469aSperry (const struct _ftsent **, const struct _ftsent **); 7021e1e24dSfvdl 719d413dceSmycroft #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ 729d413dceSmycroft #define FTS_LOGICAL 0x002 /* logical walk */ 739d413dceSmycroft #define FTS_NOCHDIR 0x004 /* don't change directories */ 749d413dceSmycroft #define FTS_NOSTAT 0x008 /* don't get stat info */ 759d413dceSmycroft #define FTS_PHYSICAL 0x010 /* physical walk */ 769d413dceSmycroft #define FTS_SEEDOT 0x020 /* return dot and dot-dot */ 7761f28255Scgd #define FTS_XDEV 0x040 /* don't cross devices */ 7804ffeab7Smycroft #define FTS_WHITEOUT 0x080 /* return whiteout information */ 7904ffeab7Smycroft #define FTS_OPTIONMASK 0x0ff /* valid user option mask */ 809d413dceSmycroft 8104ffeab7Smycroft #define FTS_NAMEONLY 0x100 /* (private) child names only */ 8204ffeab7Smycroft #define FTS_STOP 0x200 /* (private) unrecoverable error */ 839d413dceSmycroft int fts_options; /* fts_open options, global flags */ 8461f28255Scgd } FTS; 8561f28255Scgd 8661f28255Scgd typedef struct _ftsent { 879d413dceSmycroft struct _ftsent *fts_cycle; /* cycle node */ 8861f28255Scgd struct _ftsent *fts_parent; /* parent directory */ 899d413dceSmycroft struct _ftsent *fts_link; /* next file in directory */ 90a14221d5Schristos __fts_number_t fts_number; /* local numeric value */ 919d413dceSmycroft void *fts_pointer; /* local address value */ 9261f28255Scgd char *fts_accpath; /* access path */ 9361f28255Scgd char *fts_path; /* root path */ 949d413dceSmycroft int fts_errno; /* errno for this node */ 959d413dceSmycroft int fts_symfd; /* fd for symlink */ 968d5214b1Schristos __fts_length_t fts_pathlen; /* strlen(fts_path) */ 978d5214b1Schristos __fts_length_t fts_namelen; /* strlen(fts_name) */ 989d413dceSmycroft 9933037645Schristos __fts_ino_t fts_ino; /* inode */ 10050728e78Schristos __fts_dev_t fts_dev; /* device */ 10133037645Schristos __fts_nlink_t fts_nlink; /* link count */ 10261f28255Scgd 10321e1e24dSfvdl #define FTS_ROOTPARENTLEVEL -1 10421e1e24dSfvdl #define FTS_ROOTLEVEL 0 105*f2279759Schristos __fts_level_t fts_level; /* depth (-1 to N) */ 10661f28255Scgd 10721e1e24dSfvdl #define FTS_D 1 /* preorder directory */ 10821e1e24dSfvdl #define FTS_DC 2 /* directory that causes cycles */ 10921e1e24dSfvdl #define FTS_DEFAULT 3 /* none of the above */ 11021e1e24dSfvdl #define FTS_DNR 4 /* unreadable directory */ 11121e1e24dSfvdl #define FTS_DOT 5 /* dot or dot-dot */ 11221e1e24dSfvdl #define FTS_DP 6 /* postorder directory */ 11321e1e24dSfvdl #define FTS_ERR 7 /* error; errno is set */ 11421e1e24dSfvdl #define FTS_F 8 /* regular file */ 11521e1e24dSfvdl #define FTS_INIT 9 /* initialized only */ 11621e1e24dSfvdl #define FTS_NS 10 /* stat(2) failed */ 11721e1e24dSfvdl #define FTS_NSOK 11 /* no stat(2) requested */ 11821e1e24dSfvdl #define FTS_SL 12 /* symbolic link */ 11921e1e24dSfvdl #define FTS_SLNONE 13 /* symbolic link without target */ 12021e1e24dSfvdl #define FTS_W 14 /* whiteout object */ 121c293dd61Slukem unsigned short fts_info; /* user flags for FTSENT structure */ 12261f28255Scgd 12321e1e24dSfvdl #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 12421e1e24dSfvdl #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 12521e1e24dSfvdl #define FTS_ISW 0x04 /* this is a whiteout object */ 126c293dd61Slukem unsigned short fts_flags; /* private flags for FTSENT structure */ 1279d413dceSmycroft 12821e1e24dSfvdl #define FTS_AGAIN 1 /* read node again */ 12921e1e24dSfvdl #define FTS_FOLLOW 2 /* follow symbolic link */ 13021e1e24dSfvdl #define FTS_NOINSTR 3 /* no instructions */ 13121e1e24dSfvdl #define FTS_SKIP 4 /* discard node */ 132c293dd61Slukem unsigned short fts_instr; /* fts_set() instructions */ 13361f28255Scgd 13433037645Schristos __fts_stat_t *fts_statp; /* stat(2) information */ 13561f28255Scgd char fts_name[1]; /* file name */ 13661f28255Scgd } FTSENT; 13761f28255Scgd 13861f28255Scgd #include <sys/cdefs.h> 13961f28255Scgd 14061f28255Scgd __BEGIN_DECLS 14166412e72Schristos #ifndef __LIBC12_SOURCE__ 142*f2279759Schristos FTSENT *fts_children(FTS *, int) __RENAME(__fts_children60); 143*f2279759Schristos int fts_close(FTS *) __RENAME(__fts_close60); 14419b7469aSperry FTS *fts_open(char * const *, int, 145*f2279759Schristos int (*)(const FTSENT **, const FTSENT **)) __RENAME(__fts_open60); 146*f2279759Schristos FTSENT *fts_read(FTS *) __RENAME(__fts_read60); 147*f2279759Schristos int fts_set(FTS *, FTSENT *, int) __RENAME(__fts_set60); 14821e1e24dSfvdl #endif 14961f28255Scgd __END_DECLS 15061f28255Scgd 15161f28255Scgd #endif /* !_FTS_H_ */ 152