11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 13203964Simp * 3. Neither the name of the University nor the names of its contributors 141539Srgrimes * may be used to endorse or promote products derived from this software 151539Srgrimes * without specific prior written permission. 161539Srgrimes * 171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271539Srgrimes * SUCH DAMAGE. 281539Srgrimes * 2923654Speter * @(#)dirent.h 8.2 (Berkeley) 7/28/94 3053812Salfred * $FreeBSD$ 311539Srgrimes */ 321539Srgrimes 331539Srgrimes#ifndef _DIRENT_H_ 341539Srgrimes#define _DIRENT_H_ 351539Srgrimes 361539Srgrimes/* 378858Srgrimes * The kernel defines the format of directory entries returned by 381539Srgrimes * the getdirentries(2) system call. 391539Srgrimes */ 40103192Smike#include <sys/cdefs.h> 41300986Sed#include <sys/_types.h> 421539Srgrimes#include <sys/dirent.h> 431539Srgrimes 44265878Sjilles#if __XSI_VISIBLE 45300986Sed 46300986Sed#ifndef _INO_T_DECLARED 47300986Sedtypedef __ino_t ino_t; 48300986Sed#define _INO_T_DECLARED 49300986Sed#endif 50300986Sed 51103192Smike/* 52103192Smike * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer 53103192Smike * to the specification. 54103192Smike */ 55103192Smike#define d_ino d_fileno /* backward and XSI compatibility */ 561539Srgrimes 57300986Sed#endif /* __XSI_VISIBLE */ 58300986Sed 59103192Smike#if __BSD_VISIBLE 601539Srgrimes 61123257Smarcel#include <sys/_null.h> 62123257Smarcel 631539Srgrimes/* definitions for library routines operating on directories. */ 641539Srgrimes#define DIRBLKSIZ 1024 651539Srgrimes 66235647Sglebstruct _dirdesc; 67235647Sglebtypedef struct _dirdesc DIR; 6869655Sdeischen 6923654Speter/* flags for opendir2 */ 7023654Speter#define DTF_HIDEW 0x0001 /* hide whiteout entries */ 7123654Speter#define DTF_NODUP 0x0002 /* don't return duplicate names */ 7223654Speter#define DTF_REWIND 0x0004 /* rewind after reading union stack */ 7323654Speter#define __DTF_READALL 0x0008 /* everything has been read */ 74268531Sjhb#define __DTF_SKIPREAD 0x0010 /* assume internal buffer is populated */ 7523654Speter 76103192Smike#else /* !__BSD_VISIBLE */ 771539Srgrimes 78103192Smiketypedef void * DIR; 79103192Smike 80103192Smike#endif /* __BSD_VISIBLE */ 81103192Smike 8255206Speter#ifndef _KERNEL 831539Srgrimes 841539Srgrimes__BEGIN_DECLS 85201602Skib#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 86201602Skibint alphasort(const struct dirent **, const struct dirent **); 87235647Sglebint dirfd(DIR *); 88201602Skib#endif 89103192Smike#if __BSD_VISIBLE 90103192SmikeDIR *__opendir2(const char *, int); 91254499Spjdint fdclosedir(DIR *); 92103192Smikeint getdents(int, char *, int); 93103192Smikeint getdirentries(int, char *, int, long *); 94103192Smike#endif 95103111SmikeDIR *opendir(const char *); 96178256SdelphijDIR *fdopendir(int); 97103111Smikestruct dirent * 98103111Smike readdir(DIR *); 99103192Smike#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 100103192Smikeint readdir_r(DIR *, struct dirent *, struct dirent **); 101103192Smike#endif 102103111Smikevoid rewinddir(DIR *); 103201602Skib#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 104103111Smikeint scandir(const char *, struct dirent ***, 105201512Skib int (*)(const struct dirent *), int (*)(const struct dirent **, 106201512Skib const struct dirent **)); 107264042Stheraven#ifdef __BLOCKS__ 108264042Stheravenint scandir_b(const char *, struct dirent ***, 109264042Stheraven int (^)(const struct dirent *), 110264042Stheraven int (^)(const struct dirent **, const struct dirent **)); 111103192Smike#endif 112264042Stheraven#endif 113103192Smike#if __XSI_VISIBLE 114103192Smikevoid seekdir(DIR *, long); 115103192Smikelong telldir(DIR *); 116103192Smike#endif 117103192Smikeint closedir(DIR *); 1181539Srgrimes__END_DECLS 1191539Srgrimes 12055206Speter#endif /* !_KERNEL */ 1211539Srgrimes 1221539Srgrimes#endif /* !_DIRENT_H_ */ 123