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> 411539Srgrimes#include <sys/dirent.h> 421539Srgrimes 43103192Smike#if __BSD_VISIBLE || __XSI_VISIBLE 44103192Smike/* 45103192Smike * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer 46103192Smike * to the specification. 47103192Smike */ 48103192Smike#define d_ino d_fileno /* backward and XSI compatibility */ 49103192Smike#endif 501539Srgrimes 51103192Smike#if __BSD_VISIBLE 521539Srgrimes 53123257Smarcel#include <sys/_null.h> 54123257Smarcel 551539Srgrimes/* definitions for library routines operating on directories. */ 561539Srgrimes#define DIRBLKSIZ 1024 571539Srgrimes 58235647Sglebstruct _dirdesc; 59235647Sglebtypedef struct _dirdesc DIR; 6069655Sdeischen 6123654Speter/* flags for opendir2 */ 6223654Speter#define DTF_HIDEW 0x0001 /* hide whiteout entries */ 6323654Speter#define DTF_NODUP 0x0002 /* don't return duplicate names */ 6423654Speter#define DTF_REWIND 0x0004 /* rewind after reading union stack */ 6523654Speter#define __DTF_READALL 0x0008 /* everything has been read */ 66270002Sjhb#define __DTF_SKIPREAD 0x0010 /* assume internal buffer is populated */ 6723654Speter 68103192Smike#else /* !__BSD_VISIBLE */ 691539Srgrimes 70103192Smiketypedef void * DIR; 71103192Smike 72103192Smike#endif /* __BSD_VISIBLE */ 73103192Smike 7455206Speter#ifndef _KERNEL 751539Srgrimes 761539Srgrimes__BEGIN_DECLS 77201602Skib#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 78201602Skibint alphasort(const struct dirent **, const struct dirent **); 79235647Sglebint dirfd(DIR *); 80201602Skib#endif 81103192Smike#if __BSD_VISIBLE 82103192SmikeDIR *__opendir2(const char *, int); 83254499Spjdint fdclosedir(DIR *); 84103192Smikeint getdents(int, char *, int); 85103192Smikeint getdirentries(int, char *, int, long *); 86103192Smike#endif 87103111SmikeDIR *opendir(const char *); 88178256SdelphijDIR *fdopendir(int); 89103111Smikestruct dirent * 90103111Smike readdir(DIR *); 91103192Smike#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 92103192Smikeint readdir_r(DIR *, struct dirent *, struct dirent **); 93103192Smike#endif 94103111Smikevoid rewinddir(DIR *); 95201602Skib#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 96103111Smikeint scandir(const char *, struct dirent ***, 97201512Skib int (*)(const struct dirent *), int (*)(const struct dirent **, 98201512Skib const struct dirent **)); 99103192Smike#endif 100103192Smike#if __XSI_VISIBLE 101103192Smikevoid seekdir(DIR *, long); 102103192Smikelong telldir(DIR *); 103103192Smike#endif 104103192Smikeint closedir(DIR *); 1051539Srgrimes__END_DECLS 1061539Srgrimes 10755206Speter#endif /* !_KERNEL */ 1081539Srgrimes 1091539Srgrimes#endif /* !_DIRENT_H_ */ 110