kernel: bwrite_common's 3rd & 4th args can be bools
[unleashed.git] / include / dirent.h
blobf19f5c880d45e999bd154a6eb250690520175720
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 /* Copyright (c) 1988 AT&T */
30 /* All Rights Reserved */
32 #ifndef _DIRENT_H
33 #define _DIRENT_H
35 #include <sys/feature_tests.h>
37 #include <sys/types.h>
38 #include <sys/dirent.h>
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
46 #define MAXNAMLEN 512 /* maximum filename length */
47 #define DIRBUF 8192 /* buffer size for fs-indep. dirs */
49 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
51 #if !defined(__XOPEN_OR_POSIX)
53 typedef struct {
54 int dd_fd; /* file descriptor */
55 int dd_loc; /* offset in block */
56 int dd_size; /* amount of valid data */
57 char *dd_buf; /* directory block */
58 } DIR; /* stream data from opendir() */
61 #else
63 typedef struct {
64 int d_fd; /* file descriptor */
65 int d_loc; /* offset in block */
66 int d_size; /* amount of valid data */
67 char *d_buf; /* directory block */
68 } DIR; /* stream data from opendir() */
70 #endif /* !defined(__XOPEN_OR_POSIX) */
72 /* large file compilation environment setup */
73 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
74 #ifdef __PRAGMA_REDEFINE_EXTNAME
75 #pragma redefine_extname readdir readdir64
76 #pragma redefine_extname scandir scandir64
77 #pragma redefine_extname alphasort alphasort64
78 #else
79 #define readdir readdir64
80 #define scandir scandir64
81 #define alphasort alphasort64
82 #endif
83 #endif /* _FILE_OFFSET_BITS == 64 */
85 /* In the LP64 compilation environment, all APIs are already large file */
86 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
87 #ifdef __PRAGMA_REDEFINE_EXTNAME
88 #pragma redefine_extname readdir64 readdir
89 #pragma redefine_extname scandir64 scandir
90 #pragma redefine_extname alphasort64 alphasort
91 #else
92 #define readdir64 readdir
93 #define scandir64 scandir
94 #define alphsort64 alphasort
95 #endif
96 #endif /* _LP64 && _LARGEFILE64_SOURCE */
98 extern DIR *opendir(const char *);
99 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
100 defined(_ATFILE_SOURCE)
101 extern DIR *fdopendir(int);
102 extern int dirfd(DIR *);
103 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
104 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
105 extern int scandir(const char *, struct dirent *(*[]),
106 int (*)(const struct dirent *),
107 int (*)(const struct dirent **,
108 const struct dirent **));
109 extern int alphasort(const struct dirent **,
110 const struct dirent **);
111 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
112 extern struct dirent *readdir(DIR *);
113 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
114 defined(_XOPEN_SOURCE)
115 extern long telldir(DIR *);
116 extern void seekdir(DIR *, long);
117 #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
118 extern void rewinddir(DIR *);
119 extern int closedir(DIR *);
121 /* transitional large file interface */
122 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
123 !defined(__PRAGMA_REDEFINE_EXTNAME))
124 extern struct dirent64 *readdir64(DIR *);
125 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
126 extern int scandir64(const char *, struct dirent64 *(*[]),
127 int (*)(const struct dirent64 *),
128 int (*)(const struct dirent64 **,
129 const struct dirent64 **));
130 extern int alphasort64(const struct dirent64 **, const struct dirent64 **);
131 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
132 #endif
134 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
135 defined(_XOPEN_SOURCE)
136 #define rewinddir(dirp) seekdir(dirp, 0L)
137 #endif
140 * readdir_r() prototype is defined here.
142 * In the LP64 compilation environment, all APIs are already large file.
145 #if defined(_LP64)
146 #ifdef __PRAGMA_REDEFINE_EXTNAME
147 #pragma redefine_extname readdir64_r readdir_r
148 #else
149 #define readdir64_r readdir_r
150 #endif
151 #elif _FILE_OFFSET_BITS != 32
152 #ifdef __PRAGMA_REDEFINE_EXTNAME
153 #pragma redefine_extname readdir_r readdir64_r
154 #else
155 #define readdir_r readdir64_r
156 #endif
157 #endif
159 extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD,
160 struct dirent **_RESTRICT_KYWD);
162 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
163 !defined(__PRAGMA_REDEFINE_EXTNAME))
164 /* transitional large file interface */
165 extern int readdir64_r(DIR *_RESTRICT_KYWD, struct dirent64 *_RESTRICT_KYWD,
166 struct dirent64 **_RESTRICT_KYWD);
167 #endif
169 #ifdef __cplusplus
171 #endif
173 #endif /* _DIRENT_H */