1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH readdir 3UCB "30 Oct 2007" "SunOS 5.11" "SunOS/BSD Compatibility Library Functions"
.SH NAME
readdir \- read a directory entry
.SH SYNOPSIS
.LP
.nf
\fB/usr/ucb/cc\fR [ \fIflag\fR ... ] \fIfile\fR ...
#include <sys/types.h>
#include <sys/dir.h>
\fBstruct direct *\fR\fBreaddir\fR(\fIdirp\fR)
\fBDIR *\fR\fIdirp\fR;
.fi
.SH DESCRIPTION
.sp
.LP
The \fBreaddir()\fR function returns a pointer to a structure representing the
directory entry at the current position in the directory stream to which
\fIdirp\fR refers, and positions the directory stream at the next entry, except
on read-only file systems. It returns a \fINULL\fR pointer upon reaching the
end of the directory stream, or upon detecting an invalid location in the
directory. The \fBreaddir()\fR function shall not return directory entries
containing empty names. It is unspecified whether entries are returned for
dot \fB(\fR.\fB)\fR or dot-dot \fB(\fR.\|.\fB)\fR. The pointer returned by
\fBreaddir()\fR points to data that may be overwritten by another call to
\fBreaddir()\fR on the same directory stream. This data shall not be
overwritten by another call to \fBreaddir()\fR on a different directory
stream. The \fBreaddir()\fR function may buffer several directory entries per
actual read operation. The \fBreaddir()\fR function marks for update the
\fIst_atime\fR field of the directory each time the directory is actually read.
.SH RETURN VALUES
.sp
.LP
The \fBreaddir()\fR function returns \fINULL\fR on failure and sets \fBerrno\fR
to indicate the error.
.SH ERRORS
.sp
.LP
The \fBreaddir()\fR function will fail if one or more of the following are
true:
.sp
.ne 2
.mk
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 13n
.rt
Mandatory file/record locking was set, \fBO_NDELAY\fR or \fBO_NONBLOCK\fR was
set, and there was a blocking record lock.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 13n
.rt
Total amount of system memory available when reading using raw I/O is
temporarily insufficient.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 13n
.rt
No data is waiting to be read on a file associated with a tty device and
\fBO_NONBLOCK\fR was set.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 13n
.rt
No message is waiting to be read on a stream and \fBO_NDELAY\fR or
\fBO_NONBLOCK\fR was set.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEBADF\fR\fR
.ad
.RS 13n
.rt
The file descriptor determined by the \fBDIR\fR stream is no longer valid. This
results if the \fBDIR\fR stream has been closed.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEBADMSG\fR\fR
.ad
.RS 13n
.rt
Message waiting to be read on a stream is not a data message.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEDEADLK\fR\fR
.ad
.RS 13n
.rt
The \fBread()\fR was going to go to sleep and cause a deadlock to occur.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 13n
.rt
\fIbuf\fR points to an illegal address.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEINTR\fR\fR
.ad
.RS 13n
.rt
A signal was caught during the \fBread()\fR or \fBreadv()\fR function.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 13n
.rt
Attempted to read from a stream linked to a multiplexor.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEIO\fR\fR
.ad
.RS 13n
.rt
A physical I/O error has occurred, or the process is in a background process
group and is attempting to read from its controlling terminal, and either the
process is ignoring or blocking the \fBSIGTTIN\fR signal or the process group
of the process is orphaned.
.RE
.sp
.ne 2
.mk
.na
\fB\fBENOENT\fR\fR
.ad
.RS 13n
.rt
The current file pointer for the directory is not located at a valid entry.
.RE
.sp
.ne 2
.mk
.na
\fB\fBENOLCK\fR\fR
.ad
.RS 13n
.rt
The system record lock table was full, so the \fBread()\fR or \fBreadv()\fR
could not go to sleep until the blocking record lock was removed.
.RE
.sp
.ne 2
.mk
.na
\fB\fBENOLINK\fR\fR
.ad
.RS 13n
.rt
\fIfildes\fR is on a remote machine and the link to that machine is no longer
active.
.RE
.sp
.ne 2
.mk
.na
\fB\fBENXIO\fR\fR
.ad
.RS 13n
.rt
The device associated with \fIfildes\fR is a block special or character
special file and the value of the file pointer is out of range.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEOVERFLOW\fR\fR
.ad
.RS 13n
.rt
The value of the \fBdirect\fR structure member \fBd_ino\fR cannot be
represented in an \fBino_t\fR.
.RE
.SH USAGE
.sp
.LP
The \fBreaddir()\fR function has a transitional interface for 64-bit file
offsets. See \fBlf64\fR(5).
.SH SEE ALSO
.sp
.LP
\fBgetdents\fR(2), \fBreaddir\fR(3C), \fBscandir\fR(3UCB), \fBlf64\fR(5)
.SH NOTES
.sp
.LP
Use of these interfaces should be restricted to only applications written on
\fBBSD\fR platforms. Use of these interfaces with any of the system libraries
or in multi-thread applications is unsupported.
|