williamr@2
|
1 |
/*-
|
williamr@2
|
2 |
* Copyright (c) 1989, 1993
|
williamr@2
|
3 |
* The Regents of the University of California. All rights reserved.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* Redistribution and use in source and binary forms, with or without
|
williamr@2
|
6 |
* modification, are permitted provided that the following conditions
|
williamr@2
|
7 |
* are met:
|
williamr@2
|
8 |
* 1. Redistributions of source code must retain the above copyright
|
williamr@2
|
9 |
* notice, this list of conditions and the following disclaimer.
|
williamr@2
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright
|
williamr@2
|
11 |
* notice, this list of conditions and the following disclaimer in the
|
williamr@2
|
12 |
* documentation and/or other materials provided with the distribution.
|
williamr@2
|
13 |
* 4. Neither the name of the University nor the names of its contributors
|
williamr@2
|
14 |
* may be used to endorse or promote products derived from this software
|
williamr@2
|
15 |
* without specific prior written permission.
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
williamr@2
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
williamr@2
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
williamr@2
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
williamr@2
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
williamr@2
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
williamr@2
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
williamr@2
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
williamr@2
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
williamr@2
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
williamr@2
|
27 |
* SUCH DAMAGE.
|
williamr@2
|
28 |
*
|
williamr@2
|
29 |
* @(#)dirent.h 8.2 (Berkeley) 7/28/94
|
williamr@2
|
30 |
* $FreeBSD: src/include/dirent.h,v 1.14 2003/12/07 21:10:06 marcel Exp $
|
williamr@2
|
31 |
*/
|
williamr@2
|
32 |
|
williamr@2
|
33 |
#ifndef _DIRENT_H_
|
williamr@2
|
34 |
#define _DIRENT_H_
|
williamr@2
|
35 |
|
williamr@2
|
36 |
/*
|
williamr@2
|
37 |
* The kernel defines the format of directory entries returned by
|
williamr@2
|
38 |
* the getdirentries(2) system call.
|
williamr@2
|
39 |
*/
|
williamr@2
|
40 |
#include <sys/cdefs.h>
|
williamr@2
|
41 |
#include <sys/dirent.h>
|
williamr@2
|
42 |
|
williamr@2
|
43 |
#if __BSD_VISIBLE || __XSI_VISIBLE
|
williamr@2
|
44 |
/*
|
williamr@2
|
45 |
* XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer
|
williamr@2
|
46 |
* to the specification.
|
williamr@2
|
47 |
*/
|
williamr@2
|
48 |
#define d_ino d_fileno /* backward and XSI compatibility */
|
williamr@2
|
49 |
#endif
|
williamr@2
|
50 |
|
williamr@2
|
51 |
#if __BSD_VISIBLE
|
williamr@2
|
52 |
|
williamr@2
|
53 |
#include <sys/_null.h>
|
williamr@2
|
54 |
|
williamr@2
|
55 |
/* definitions for library routines operating on directories. */
|
williamr@2
|
56 |
#define DIRBLKSIZ 1024
|
williamr@2
|
57 |
|
williamr@2
|
58 |
struct _telldir; /* see telldir.h */
|
williamr@2
|
59 |
|
williamr@2
|
60 |
/* structure describing an open directory. */
|
williamr@2
|
61 |
typedef struct _dirdesc {
|
williamr@2
|
62 |
int dd_fd; /* file descriptor associated with directory */
|
williamr@2
|
63 |
long dd_loc; /* offset in current buffer */
|
williamr@2
|
64 |
long dd_size; /* amount of data returned by getdirentries */
|
williamr@2
|
65 |
char *dd_buf; /* data buffer */
|
williamr@2
|
66 |
int dd_len; /* size of data buffer */
|
williamr@2
|
67 |
long dd_seek; /* magic cookie returned by getdirentries */
|
williamr@2
|
68 |
long dd_rewind; /* magic cookie for rewinding */
|
williamr@2
|
69 |
int dd_flags; /* flags for readdir */
|
williamr@2
|
70 |
void *dd_lock; /* hack to avoid including <pthread.h> */
|
williamr@2
|
71 |
struct _telldir *dd_td; /* telldir position recording */
|
williamr@2
|
72 |
} DIR;
|
williamr@2
|
73 |
|
williamr@2
|
74 |
#define dirfd(dirp) ((dirp)->dd_fd)
|
williamr@2
|
75 |
|
williamr@2
|
76 |
/* flags for opendir2 */
|
williamr@2
|
77 |
#define DTF_HIDEW 0x0001 /* hide whiteout entries */
|
williamr@2
|
78 |
#define DTF_NODUP 0x0002 /* don't return duplicate names */
|
williamr@2
|
79 |
#define DTF_REWIND 0x0004 /* rewind after reading union stack */
|
williamr@2
|
80 |
#define __DTF_READALL 0x0008 /* everything has been read */
|
williamr@2
|
81 |
|
williamr@2
|
82 |
#else /* !__BSD_VISIBLE */
|
williamr@2
|
83 |
|
williamr@2
|
84 |
typedef void * DIR;
|
williamr@2
|
85 |
|
williamr@2
|
86 |
#endif /* __BSD_VISIBLE */
|
williamr@2
|
87 |
|
williamr@2
|
88 |
#ifndef _KERNEL
|
williamr@2
|
89 |
|
williamr@2
|
90 |
__BEGIN_DECLS
|
williamr@2
|
91 |
#if __BSD_VISIBLE
|
williamr@2
|
92 |
IMPORT_C int alphasort(const void *, const void *);
|
williamr@2
|
93 |
/* #define getdirentries _getdirentries */
|
williamr@2
|
94 |
IMPORT_C int getdirentries(int, char *, int, long *);
|
williamr@2
|
95 |
#endif
|
williamr@2
|
96 |
IMPORT_C DIR *opendir(const char *);
|
williamr@2
|
97 |
IMPORT_C struct dirent *
|
williamr@2
|
98 |
readdir(DIR *);
|
williamr@2
|
99 |
IMPORT_C void rewinddir(DIR *);
|
williamr@2
|
100 |
IMPORT_C int alphasort(const void *, const void *);
|
williamr@2
|
101 |
IMPORT_C int scandir(const char *, struct dirent ***,
|
williamr@2
|
102 |
int (*)(struct dirent *), int (*)(const void *, const void *));
|
williamr@2
|
103 |
#if __XSI_VISIBLE
|
williamr@2
|
104 |
IMPORT_C void seekdir(DIR *, long);
|
williamr@2
|
105 |
IMPORT_C long telldir(DIR *);
|
williamr@2
|
106 |
#endif
|
williamr@2
|
107 |
IMPORT_C int closedir(DIR *);
|
williamr@2
|
108 |
__END_DECLS
|
williamr@2
|
109 |
|
williamr@2
|
110 |
#endif /* !_KERNEL */
|
williamr@2
|
111 |
|
williamr@2
|
112 |
#endif /* !_DIRENT_H_ */
|