1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\" Modified Sat Jul 24 18:46:01 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 11 June 1995 by Andries Brouwer (aeb@cwi.nl)
31 .\" 2007-07-30 Ulrich Drepper <drepper@redhat.com>: document fdopendir().
32 .TH OPENDIR 3 2017-09-15 "GNU" "Linux Programmer's Manual"
34 opendir, fdopendir \- open a directory
37 .B #include <sys/types.h>
38 .B #include <dirent.h>
40 .BI "DIR *opendir(const char *" name );
41 .BI "DIR *fdopendir(int " fd );
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
55 _POSIX_C_SOURCE\ >=\ 200809L
65 function opens a directory stream corresponding to the
66 directory \fIname\fP, and returns a pointer to the directory stream.
67 The stream is positioned at the first entry in the directory.
74 but returns a directory stream for the directory referred
75 to by the open file descriptor
77 After a successful call to
80 is used internally by the implementation,
81 and should not otherwise be used by the application.
87 functions return a pointer to the directory stream.
88 On error, NULL is returned, and
98 is not a valid file descriptor opened for reading.
101 The per-process limit on the number of open file descriptors has been reached.
104 The system-wide limit on the total number of open files has been reached.
107 Directory does not exist, or \fIname\fP is an empty string.
110 Insufficient memory to complete the operation.
113 \fIname\fP is not a directory.
116 is available in glibc since version 2.4.
118 For an explanation of the terms used in this section, see
124 Interface Attribute Value
128 T} Thread safety MT-Safe
132 is present on SVr4, 4.3BSD, and specified in POSIX.1-2001.
134 is specified in POSIX.1-2008.
136 Filename entries can be read from a directory stream using
139 The underlying file descriptor of the directory stream can be obtained using
144 function sets the close-on-exec flag for the file descriptor underlying the
148 function leaves the setting of the close-on-exec
149 flag unchanged for the file descriptor,
151 POSIX.1-200x leaves it unspecified whether a successful call to
153 will set the close-on-exec flag for the file descriptor,