1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sat Jul 24 18:46:01 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 11 June 1995 by Andries Brouwer (aeb@cwi.nl)
29 .\" 2007-07-30 Ulrich Drepper <drepper@redhat.com>: document fdopendir().
30 .TH OPENDIR 3 2010-06-20 "GNU" "Linux Programmer's Manual"
32 opendir, fdopendir \- open a directory
35 .B #include <sys/types.h>
37 .B #include <dirent.h>
39 .BI "DIR *opendir(const char *" name );
40 .BI "DIR *fdopendir(int " fd );
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
54 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
64 function opens a directory stream corresponding to the
65 directory \fIname\fP, and returns a pointer to the directory stream.
66 The stream is positioned at the first entry in the directory.
73 but returns a directory stream for the directory referred
74 to by the open file descriptor
76 After a successful call to
79 is used internally by the implementation,
80 and should not otherwise be used by the application.
86 functions return a pointer to the directory stream.
87 On error, NULL is returned, and
97 is not a valid file descriptor opened for reading.
100 Too many file descriptors in use by process.
103 Too many files are currently open in the system.
106 Directory does not exist, or \fIname\fP is an empty string.
109 Insufficient memory to complete the operation.
112 \fIname\fP is not a directory.
115 is available in glibc since version 2.4.
118 is present on SVr4, 4.3BSD, and specified in POSIX.1-2001.
120 is specified in POSIX.1-2008.
122 The underlying file descriptor of the directory stream can be obtained using
127 function sets the close-on-exec flag for the file descriptor underlying the
131 function leaves the setting of the close-on-exec
132 flag unchanged for the file descriptor,
134 POSIX.1-200x leaves it unspecified whether a successful call to
136 will set the close-on-exec flag for the file descriptor,