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 * 3. All advertising materials mentioning features or use of this software 00014 * must display the following acknowledgement: 00015 * This product includes software developed by the University of 00016 * California, Berkeley and its contributors. 00017 * 4. Neither the name of the University nor the names of its contributors 00018 * may be used to endorse or promote products derived from this software 00019 * without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00022 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00024 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00025 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00026 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00027 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00028 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00029 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00030 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * @(#)dirent.h 8.2 (Berkeley) 7/28/94 00034 * $FreeBSD: src/include/dirent.h,v 1.14 2003/12/07 21:10:06 marcel Exp $ 00035 */ 00036 00037 #ifndef _DIRENT_H_ 00038 #define _DIRENT_H_ 00039 00040 /* 00041 * The kernel defines the format of directory entries returned by 00042 * the getdirentries(2) system call. 00043 */ 00044 #include <sys/cdefs.h> 00045 #include <sys/dirent.h> 00046 00047 #if __BSD_VISIBLE || __XSI_VISIBLE 00048 /* 00049 * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer 00050 * to the specification. 00051 */ 00052 #define d_ino d_fileno /* backward and XSI compatibility */ 00053 #endif 00054 00055 #if __BSD_VISIBLE 00056 00057 #include <sys/_null.h> 00058 00059 /* definitions for library routines operating on directories. */ 00060 #define DIRBLKSIZ 1024 00061 00062 struct _telldir; /* see telldir.h */ 00063 00064 /* structure describing an open directory. */ 00065 typedef struct _dirdesc { 00066 int dd_fd; /* file descriptor associated with directory */ 00067 long dd_loc; /* offset in current buffer */ 00068 long dd_size; /* amount of data returned by getdirentries */ 00069 char *dd_buf; /* data buffer */ 00070 int dd_len; /* size of data buffer */ 00071 long dd_seek; /* magic cookie returned by getdirentries */ 00072 long dd_rewind; /* magic cookie for rewinding */ 00073 int dd_flags; /* flags for readdir */ 00074 void *dd_lock; /* hack to avoid including <pthread.h> */ 00075 struct _telldir *dd_td; /* telldir position recording */ 00076 } DIR; 00077 00078 #define dirfd(dirp) ((dirp)->dd_fd) 00079 00080 /* flags for opendir2 */ 00081 #define DTF_HIDEW 0x0001 /* hide whiteout entries */ 00082 #define DTF_NODUP 0x0002 /* don't return duplicate names */ 00083 #define DTF_REWIND 0x0004 /* rewind after reading union stack */ 00084 #define __DTF_READALL 0x0008 /* everything has been read */ 00085 00086 #else /* !__BSD_VISIBLE */ 00087 00088 typedef void * DIR; 00089 00090 #endif /* __BSD_VISIBLE */ 00091 00092 #ifndef _KERNEL 00093 00094 __BEGIN_DECLS 00095 #if __BSD_VISIBLE 00096 IMPORT_C int alphasort(const void *, const void *); 00097 /* #define getdirentries _getdirentries */ 00098 IMPORT_C int getdirentries(int, char *, int, long *); 00099 #endif 00100 IMPORT_C DIR *opendir(const char *); 00101 IMPORT_C struct dirent * 00102 readdir(DIR *); 00103 IMPORT_C void rewinddir(DIR *); 00104 IMPORT_C int alphasort(const void *, const void *); 00105 IMPORT_C int scandir(const char *, struct dirent ***, 00106 int (*)(struct dirent *), int (*)(const void *, const void *)); 00107 #if __XSI_VISIBLE 00108 IMPORT_C void seekdir(DIR *, long); 00109 IMPORT_C long telldir(DIR *); 00110 #endif 00111 IMPORT_C int closedir(DIR *); 00112 __END_DECLS 00113 00114 #endif /* !_KERNEL */ 00115 00116 #endif /* !_DIRENT_H_ */