9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / opendir.3c
blobfa35c1aca9bf1e171f653cfd81ba5093f1aff2ce
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
45 .\"
46 .TH OPENDIR 3C "Jun 26, 2007"
47 .SH NAME
48 opendir, fdopendir \- open directory
49 .SH SYNOPSIS
50 .LP
51 .nf
52 #include <sys/types.h>
53 #include <dirent.h>
55 \fBDIR *\fR\fBopendir\fR(\fBconst char *\fR\fIdirname\fR);
56 .fi
58 .LP
59 .nf
60 \fBDIR *\fR\fBfdopendir\fR(\fBint\fR \fIfildes\fR);
61 .fi
63 .SH DESCRIPTION
64 .sp
65 .LP
66 The \fBopendir()\fR function opens a directory stream corresponding to the
67 directory named by the \fIdirname\fR argument.
68 .sp
69 .LP
70 The \fBfdopendir()\fR function opens a directory stream for the directory file
71 descriptor \fIfildes\fR. The directory file descriptor should not be used or
72 closed following a successful function call, as this might cause undefined
73 results from future operations on the directory stream obtained from the call.
74 Use \fBclosedir\fR(3C) to close a directory stream.
75 .sp
76 .LP
77 The directory stream is positioned at the first entry. If the type \fBDIR\fR is
78 implemented using a file descriptor, applications will only be able to open up
79 to a total of {\fBOPEN_MAX\fR} files and directories. A successful call to any
80 of the \fBexec\fR functions will close any directory streams that are open in
81 the calling process.  See \fBexec\fR(2).
82 .SH RETURN VALUES
83 .sp
84 .LP
85 Upon successful completion, \fBopendir()\fR and \fBfdopendir()\fR return a
86 pointer to an object of type \fBDIR\fR. Otherwise, a null pointer is returned
87 and \fBerrno\fR is set to indicate the error.
88 .SH ERRORS
89 .sp
90 .LP
91 The \fBopendir()\fR function will fail if:
92 .sp
93 .ne 2
94 .na
95 \fB\fBEACCES\fR\fR
96 .ad
97 .RS 16n
98 Search permission is denied for the component of the path prefix of
99 \fIdirname\fR or read permission is denied for \fIdirname\fR.
103 .ne 2
105 \fB\fBELOOP\fR\fR
107 .RS 16n
108 Too many symbolic links were encountered in resolving \fIpath\fR.
112 .ne 2
114 \fB\fBENAMETOOLONG\fR\fR
116 .RS 16n
117 The length of the \fIdirname\fR argument exceeds {\fBPATH_MAX\fR}, or a path
118 name component is longer than {\fBNAME_MAX\fR} while {\fB_POSIX_NO_TRUNC\fR} is
119 in effect.
123 .ne 2
125 \fB\fBENOENT\fR\fR
127 .RS 16n
128 A component of \fIdirname\fR does not name an existing directory or
129 \fIdirname\fR is an empty string.
133 .ne 2
135 \fB\fBENOTDIR\fR\fR
137 .RS 16n
138 A component of \fIdirname\fR is not a directory.
143 The \fBfdopendir()\fR function will fail if:
145 .ne 2
147 \fB\fBENOTDIR\fR\fR
149 .RS 11n
150 The file descriptor \fIfildes\fR does not reference a directory.
155 The \fBopendir()\fR function may fail if:
157 .ne 2
159 \fB\fBEMFILE\fR\fR
161 .RS 16n
162 There are {\fBOPEN_MAX\fR} file descriptors currently open in the calling
163 process.
167 .ne 2
169 \fB\fBENAMETOOLONG\fR\fR
171 .RS 16n
172 Pathname resolution of a symbolic link produced an intermediate result whose
173 length exceeds \fBPATH_MAX\fR.
177 .ne 2
179 \fB\fBENFILE\fR\fR
181 .RS 16n
182 Too many files are currently open on the system.
185 .SH USAGE
188 The \fBopendir()\fR and \fBfdopendir()\fR functions should be used in
189 conjunction with \fBreaddir\fR(3C), \fBclosedir\fR(3C) and \fBrewinddir\fR(3C)
190 to examine the contents of the directory (see the \fBEXAMPLES\fR section in
191 \fBreaddir\fR(3C)). This method is recommended for portability.
192 .SH ATTRIBUTES
195 See \fBattributes\fR(5) for descriptions of the following attributes:
200 box;
201 c | c
202 l | l .
203 ATTRIBUTE TYPE  ATTRIBUTE VALUE
205 Interface Stability     T{
206 \fBopendir()\fR is Standard; \fBfdopendir()\fR is Evolving
209 MT-Level        Safe
212 .SH SEE ALSO
215 \fBlstat\fR(2), \fBsymlink\fR(2), \fBclosedir\fR(3C), \fBreaddir\fR(3C),
216 \fBrewinddir\fR(3C), \fBscandir\fR(3C), \fBattributes\fR(5)