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 */
6623654Speter
67103192Smike#else /* !__BSD_VISIBLE */
681539Srgrimes
69103192Smiketypedef	void *	DIR;
70103192Smike
71103192Smike#endif /* __BSD_VISIBLE */
72103192Smike
7355206Speter#ifndef _KERNEL
741539Srgrimes
751539Srgrimes__BEGIN_DECLS
76201602Skib#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700
77201602Skibint	 alphasort(const struct dirent **, const struct dirent **);
78235647Sglebint	 dirfd(DIR *);
79201602Skib#endif
80103192Smike#if __BSD_VISIBLE
81103192SmikeDIR	*__opendir2(const char *, int);
82254499Spjdint	 fdclosedir(DIR *);
83103192Smikeint	 getdents(int, char *, int);
84103192Smikeint	 getdirentries(int, char *, int, long *);
85103192Smike#endif
86103111SmikeDIR	*opendir(const char *);
87178256SdelphijDIR	*fdopendir(int);
88103111Smikestruct dirent *
89103111Smike	 readdir(DIR *);
90103192Smike#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
91103192Smikeint	 readdir_r(DIR *, struct dirent *, struct dirent **);
92103192Smike#endif
93103111Smikevoid	 rewinddir(DIR *);
94201602Skib#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700
95103111Smikeint	 scandir(const char *, struct dirent ***,
96201512Skib	    int (*)(const struct dirent *), int (*)(const struct dirent **,
97201512Skib	    const struct dirent **));
98103192Smike#endif
99103192Smike#if __XSI_VISIBLE
100103192Smikevoid	 seekdir(DIR *, long);
101103192Smikelong	 telldir(DIR *);
102103192Smike#endif
103103192Smikeint	 closedir(DIR *);
1041539Srgrimes__END_DECLS
1051539Srgrimes
10655206Speter#endif /* !_KERNEL */
1071539Srgrimes
1081539Srgrimes#endif /* !_DIRENT_H_ */
109