xref: /original-bsd/include/dirent.h (revision 065e4d72)
1 /*-
2  * Copyright (c) 1989, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dirent.h	8.2 (Berkeley) 07/28/94
8  */
9 
10 #ifndef _DIRENT_H_
11 #define _DIRENT_H_
12 
13 /*
14  * The kernel defines the format of directory entries returned by
15  * the getdirentries(2) system call.
16  */
17 #include <sys/dirent.h>
18 
19 #ifdef _POSIX_SOURCE
20 typedef void *	DIR;
21 #else
22 
23 #define	d_ino		d_fileno	/* backward compatibility */
24 
25 /* definitions for library routines operating on directories. */
26 #define	DIRBLKSIZ	1024
27 
28 /* structure describing an open directory. */
29 typedef struct _dirdesc {
30 	int	dd_fd;		/* file descriptor associated with directory */
31 	long	dd_loc;		/* offset in current buffer */
32 	long	dd_size;	/* amount of data returned by getdirentries */
33 	char	*dd_buf;	/* data buffer */
34 	int	dd_len;		/* size of data buffer */
35 	long	dd_seek;	/* magic cookie returned by getdirentries */
36 	long	dd_rewind;	/* magic cookie for rewinding */
37 	int	dd_flags;	/* flags for readdir */
38 } DIR;
39 
40 #define	dirfd(dirp)	((dirp)->dd_fd)
41 
42 /* flags for opendir2 */
43 #define DTF_HIDEW	0x0001	/* hide whiteout entries */
44 #define DTF_NODUP	0x0002	/* don't return duplicate names */
45 #define DTF_REWIND	0x0004	/* rewind after reading union stack */
46 #define __DTF_READALL	0x0008	/* everything has been read */
47 
48 #ifndef NULL
49 #define	NULL	0
50 #endif
51 
52 #endif /* _POSIX_SOURCE */
53 
54 #ifndef KERNEL
55 
56 #include <sys/cdefs.h>
57 
58 __BEGIN_DECLS
59 DIR *opendir __P((const char *));
60 struct dirent *readdir __P((DIR *));
61 void rewinddir __P((DIR *));
62 int closedir __P((DIR *));
63 #ifndef _POSIX_SOURCE
64 DIR *__opendir2 __P((const char *, int));
65 long telldir __P((const DIR *));
66 void seekdir __P((DIR *, long));
67 int scandir __P((const char *, struct dirent ***,
68     int (*)(struct dirent *), int (*)(const void *, const void *)));
69 int alphasort __P((const void *, const void *));
70 int getdirentries __P((int, char *, int, long *));
71 #endif /* not POSIX */
72 __END_DECLS
73 
74 #endif /* !KERNEL */
75 
76 #endif /* !_DIRENT_H_ */
77