williamr@2: /*- williamr@2: * Copyright (c) 1989, 1993 williamr@2: * The Regents of the University of California. All rights reserved. williamr@2: * williamr@2: * Redistribution and use in source and binary forms, with or without williamr@2: * modification, are permitted provided that the following conditions williamr@2: * are met: williamr@2: * 1. Redistributions of source code must retain the above copyright williamr@2: * notice, this list of conditions and the following disclaimer. williamr@2: * 2. Redistributions in binary form must reproduce the above copyright williamr@2: * notice, this list of conditions and the following disclaimer in the williamr@2: * documentation and/or other materials provided with the distribution. williamr@2: * 4. Neither the name of the University nor the names of its contributors williamr@2: * may be used to endorse or promote products derived from this software williamr@2: * without specific prior written permission. williamr@2: * williamr@2: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND williamr@2: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE williamr@2: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE williamr@2: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE williamr@2: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL williamr@2: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS williamr@2: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) williamr@2: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT williamr@2: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY williamr@2: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF williamr@2: * SUCH DAMAGE. williamr@2: * williamr@2: * @(#)dirent.h 8.2 (Berkeley) 7/28/94 williamr@2: * $FreeBSD: src/include/dirent.h,v 1.14 2003/12/07 21:10:06 marcel Exp $ williamr@2: */ williamr@2: williamr@2: #ifndef _DIRENT_H_ williamr@2: #define _DIRENT_H_ williamr@2: williamr@2: /* williamr@2: * The kernel defines the format of directory entries returned by williamr@2: * the getdirentries(2) system call. williamr@2: */ williamr@2: #include williamr@2: #include williamr@2: williamr@2: #if __BSD_VISIBLE || __XSI_VISIBLE williamr@2: /* williamr@2: * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer williamr@2: * to the specification. williamr@2: */ williamr@2: #define d_ino d_fileno /* backward and XSI compatibility */ williamr@2: #endif williamr@2: williamr@2: #if __BSD_VISIBLE williamr@2: williamr@2: #include williamr@2: williamr@2: /* definitions for library routines operating on directories. */ williamr@2: #define DIRBLKSIZ 1024 williamr@2: williamr@2: struct _telldir; /* see telldir.h */ williamr@2: williamr@2: /* structure describing an open directory. */ williamr@2: typedef struct _dirdesc { williamr@2: int dd_fd; /* file descriptor associated with directory */ williamr@2: long dd_loc; /* offset in current buffer */ williamr@2: long dd_size; /* amount of data returned by getdirentries */ williamr@2: char *dd_buf; /* data buffer */ williamr@2: int dd_len; /* size of data buffer */ williamr@2: long dd_seek; /* magic cookie returned by getdirentries */ williamr@2: long dd_rewind; /* magic cookie for rewinding */ williamr@2: int dd_flags; /* flags for readdir */ williamr@2: void *dd_lock; /* hack to avoid including */ williamr@2: struct _telldir *dd_td; /* telldir position recording */ williamr@2: } DIR; williamr@2: williamr@2: #define dirfd(dirp) ((dirp)->dd_fd) williamr@2: williamr@2: /* flags for opendir2 */ williamr@2: #define DTF_HIDEW 0x0001 /* hide whiteout entries */ williamr@2: #define DTF_NODUP 0x0002 /* don't return duplicate names */ williamr@2: #define DTF_REWIND 0x0004 /* rewind after reading union stack */ williamr@2: #define __DTF_READALL 0x0008 /* everything has been read */ williamr@2: williamr@2: #else /* !__BSD_VISIBLE */ williamr@2: williamr@2: typedef void * DIR; williamr@2: williamr@2: #endif /* __BSD_VISIBLE */ williamr@2: williamr@2: #ifndef _KERNEL williamr@2: williamr@2: __BEGIN_DECLS williamr@2: #if __BSD_VISIBLE williamr@2: IMPORT_C int alphasort(const void *, const void *); williamr@2: /* #define getdirentries _getdirentries */ williamr@2: IMPORT_C int getdirentries(int, char *, int, long *); williamr@2: #endif williamr@2: IMPORT_C DIR *opendir(const char *); williamr@2: IMPORT_C struct dirent * williamr@2: readdir(DIR *); williamr@2: IMPORT_C void rewinddir(DIR *); williamr@2: IMPORT_C int alphasort(const void *, const void *); williamr@2: IMPORT_C int scandir(const char *, struct dirent ***, williamr@2: int (*)(struct dirent *), int (*)(const void *, const void *)); williamr@2: #if __XSI_VISIBLE williamr@2: IMPORT_C void seekdir(DIR *, long); williamr@2: IMPORT_C long telldir(DIR *); williamr@2: #endif williamr@2: IMPORT_C int closedir(DIR *); williamr@2: __END_DECLS williamr@2: williamr@2: #endif /* !_KERNEL */ williamr@2: williamr@2: #endif /* !_DIRENT_H_ */