2 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 18:46:01 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified 11 June 1995 by Andries Brouwer (aeb@cwi.nl)
12 .\" 2007-07-30 Ulrich Drepper <drepper@redhat.com>: document fdopendir().
13 .TH opendir 3 (date) "Linux man-pages (unreleased)"
15 opendir, fdopendir \- open a directory
18 .RI ( libc ", " \-lc )
21 .B #include <sys/types.h>
22 .B #include <dirent.h>
24 .BI "DIR *opendir(const char *" name );
25 .BI "DIR *fdopendir(int " fd );
29 Feature Test Macro Requirements for glibc (see
30 .BR feature_test_macros (7)):
36 _POSIX_C_SOURCE >= 200809L
43 function opens a directory stream corresponding to the
44 directory \fIname\fP, and returns a pointer to the directory stream.
45 The stream is positioned at the first entry in the directory.
52 but returns a directory stream for the directory referred
53 to by the open file descriptor
55 After a successful call to
58 is used internally by the implementation,
59 and should not otherwise be used by the application.
65 functions return a pointer to the directory stream.
66 On error, NULL is returned, and
68 is set to indicate the error.
76 is not a valid file descriptor opened for reading.
79 The per-process limit on the number of open file descriptors has been reached.
82 The system-wide limit on the total number of open files has been reached.
85 Directory does not exist, or \fIname\fP is an empty string.
88 Insufficient memory to complete the operation.
91 \fIname\fP is not a directory.
93 For an explanation of the terms used in this section, see
101 Interface Attribute Value
105 T} Thread safety MT-Safe
115 SVr4, 4.3BSD, POSIX.1-2001.
121 Filename entries can be read from a directory stream using
124 The underlying file descriptor of the directory stream can be obtained using
129 function sets the close-on-exec flag for the file descriptor underlying the
133 function leaves the setting of the close-on-exec
134 flag unchanged for the file descriptor,
136 POSIX.1-200x leaves it unspecified whether a successful call to
138 will set the close-on-exec flag for the file descriptor,