1OPENDIR(3) Linux Programmer's Manual OPENDIR(3)
2
3
4
6 opendir, fdopendir - open a directory
7
9 #include <sys/types.h>
10 #include <dirent.h>
11
12 DIR *opendir(const char *name);
13 DIR *fdopendir(int fd);
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 fdopendir():
18 Since glibc 2.10: _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
19 Before glibc 2.10: _GNU_SOURCE
20
22 The opendir() function opens a directory stream corresponding to the
23 directory name, and returns a pointer to the directory stream. The
24 stream is positioned at the first entry in the directory.
25
26 The fdopendir() function is like opendir(), but returns a directory
27 stream for the directory referred to by the open file descriptor fd.
28 After a successful call to fdopendir(), fd is used internally by the
29 implementation, and should not otherwise be used by the application.
30
32 The opendir() and fdopendir() functions return a pointer to the direc‐
33 tory stream. On error, NULL is returned, and errno is set appropri‐
34 ately.
35
37 EACCES Permission denied.
38
39 EBADF fd is not a valid file descriptor opened for reading.
40
41 EMFILE Too many file descriptors in use by process.
42
43 ENFILE Too many files are currently open in the system.
44
45 ENOENT Directory does not exist, or name is an empty string.
46
47 ENOMEM Insufficient memory to complete the operation.
48
49 ENOTDIR
50 name is not a directory.
51
53 fdopendir() is available in glibc since version 2.4.
54
56 opendir() is present on SVr4, 4.3BSD, and specified in POSIX.1-2001.
57 fdopendir() is specified in POSIX.1-2008.
58
60 The underlying file descriptor of the directory stream can be obtained
61 using dirfd(3).
62
63 The opendir() function sets the close-on-exec flag for the file
64 descriptor underlying the DIR *. The fdopendir() function leaves the
65 setting of the close-on-exec flag unchanged for the file descriptor,
66 fd. POSIX.1-200x leaves it unspecified whether a successful call to
67 fdopendir() will set the close-on-exec flag for the file descriptor,
68 fd.
69
71 open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3),
72 seekdir(3), telldir(3)
73
75 This page is part of release 3.25 of the Linux man-pages project. A
76 description of the project, and information about reporting bugs, can
77 be found at http://www.kernel.org/doc/man-pages/.
78
79
80
81GNU 2010-06-20 OPENDIR(3)