Back to index

glibc  2.9
fts.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1989, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *     @(#)fts.h     8.3 (Berkeley) 8/14/94
00030  */
00031 
00032 #ifndef       _FTS_H
00033 #define       _FTS_H 1
00034 
00035 #include <features.h>
00036 #include <sys/types.h>
00037 
00038 /* The fts interface is incompatible with the LFS interface which
00039    transparently uses the 64-bit file access functions.  */
00040 #ifdef __USE_FILE_OFFSET64
00041 # error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
00042 #endif
00043 
00044 
00045 typedef struct {
00046        struct _ftsent *fts_cur;    /* current node */
00047        struct _ftsent *fts_child;  /* linked list of children */
00048        struct _ftsent **fts_array; /* sort array */
00049        dev_t fts_dev;                     /* starting device # */
00050        char *fts_path;                    /* path for this descent */
00051        int fts_rfd;                /* fd for root */
00052        int fts_pathlen;            /* sizeof(path) */
00053        int fts_nitems;                    /* elements in the sort array */
00054        int (*fts_compar) (const void *, const void *); /* compare fn */
00055 
00056 #define       FTS_COMFOLLOW 0x0001        /* follow command line symlinks */
00057 #define       FTS_LOGICAL   0x0002        /* logical walk */
00058 #define       FTS_NOCHDIR   0x0004        /* don't change directories */
00059 #define       FTS_NOSTAT    0x0008        /* don't get stat info */
00060 #define       FTS_PHYSICAL  0x0010        /* physical walk */
00061 #define       FTS_SEEDOT    0x0020        /* return dot and dot-dot */
00062 #define       FTS_XDEV      0x0040        /* don't cross devices */
00063 #define FTS_WHITEOUT 0x0080        /* return whiteout information */
00064 #define       FTS_OPTIONMASK       0x00ff        /* valid user option mask */
00065 
00066 #define       FTS_NAMEONLY  0x0100        /* (private) child names only */
00067 #define       FTS_STOP      0x0200        /* (private) unrecoverable error */
00068        int fts_options;            /* fts_open options, global flags */
00069 } FTS;
00070 
00071 typedef struct _ftsent {
00072        struct _ftsent *fts_cycle;  /* cycle node */
00073        struct _ftsent *fts_parent; /* parent directory */
00074        struct _ftsent *fts_link;   /* next file in directory */
00075        long fts_number;             /* local numeric value */
00076        void *fts_pointer;           /* local address value */
00077        char *fts_accpath;          /* access path */
00078        char *fts_path;                    /* root path */
00079        int fts_errno;                     /* errno for this node */
00080        int fts_symfd;                     /* fd for symlink */
00081        u_short fts_pathlen;        /* strlen(fts_path) */
00082        u_short fts_namelen;        /* strlen(fts_name) */
00083 
00084        ino_t fts_ino;                     /* inode */
00085        dev_t fts_dev;                     /* device */
00086        nlink_t fts_nlink;          /* link count */
00087 
00088 #define       FTS_ROOTPARENTLEVEL  -1
00089 #define       FTS_ROOTLEVEL         0
00090        short fts_level;            /* depth (-1 to N) */
00091 
00092 #define       FTS_D          1            /* preorder directory */
00093 #define       FTS_DC         2            /* directory that causes cycles */
00094 #define       FTS_DEFAULT    3            /* none of the above */
00095 #define       FTS_DNR               4            /* unreadable directory */
00096 #define       FTS_DOT               5            /* dot or dot-dot */
00097 #define       FTS_DP         6            /* postorder directory */
00098 #define       FTS_ERR               7            /* error; errno is set */
00099 #define       FTS_F          8            /* regular file */
00100 #define       FTS_INIT       9            /* initialized only */
00101 #define       FTS_NS        10            /* stat(2) failed */
00102 #define       FTS_NSOK      11            /* no stat(2) requested */
00103 #define       FTS_SL        12            /* symbolic link */
00104 #define       FTS_SLNONE    13            /* symbolic link without target */
00105 #define FTS_W        14            /* whiteout object */
00106        u_short fts_info;           /* user flags for FTSENT structure */
00107 
00108 #define       FTS_DONTCHDIR  0x01         /* don't chdir .. to the parent */
00109 #define       FTS_SYMFOLLOW  0x02         /* followed a symlink to get here */
00110        u_short fts_flags;          /* private flags for FTSENT structure */
00111 
00112 #define       FTS_AGAIN      1            /* read node again */
00113 #define       FTS_FOLLOW     2            /* follow symbolic link */
00114 #define       FTS_NOINSTR    3            /* no instructions */
00115 #define       FTS_SKIP       4            /* discard node */
00116        u_short fts_instr;          /* fts_set() instructions */
00117 
00118        struct stat *fts_statp;            /* stat(2) information */
00119        char fts_name[1];           /* file name */
00120 } FTSENT;
00121 
00122 __BEGIN_DECLS
00123 FTSENT *fts_children (FTS *, int);
00124 int     fts_close (FTS *);
00125 FTS    *fts_open (char * const *, int,
00126                  int (*)(const FTSENT **, const FTSENT **));
00127 FTSENT *fts_read (FTS *);
00128 int     fts_set (FTS *, FTSENT *, int) __THROW;
00129 __END_DECLS
00130 
00131 #endif /* fts.h */