1OPENDIR(3)                 Linux Programmer's Manual                OPENDIR(3)
2
3
4

NAME

6       opendir, fdopendir - open a directory
7

SYNOPSIS

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:
19               _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
20           Before glibc 2.10:
21               _GNU_SOURCE
22

DESCRIPTION

24       The  opendir()  function  opens a directory stream corresponding to the
25       directory name, and returns a pointer to  the  directory  stream.   The
26       stream is positioned at the first entry in the directory.
27
28       The  fdopendir()  function  is  like opendir(), but returns a directory
29       stream for the directory referred to by the open  file  descriptor  fd.
30       After  a  successful  call to fdopendir(), fd is used internally by the
31       implementation, and should not otherwise be used by the application.
32

RETURN VALUE

34       The opendir() and fdopendir() functions return a pointer to the  direc‐
35       tory  stream.   On  error, NULL is returned, and errno is set appropri‐
36       ately.
37

ERRORS

39       EACCES Permission denied.
40
41       EBADF  fd is not a valid file descriptor opened for reading.
42
43       EMFILE Too many file descriptors in use by process.
44
45       ENFILE Too many files are currently open in the system.
46
47       ENOENT Directory does not exist, or name is an empty string.
48
49       ENOMEM Insufficient memory to complete the operation.
50
51       ENOTDIR
52              name is not a directory.
53

VERSIONS

55       fdopendir() is available in glibc since version 2.4.
56

CONFORMING TO

58       opendir() is present on SVr4, 4.3BSD, and  specified  in  POSIX.1-2001.
59       fdopendir() is specified in POSIX.1-2008.
60

NOTES

62       The  underlying file descriptor of the directory stream can be obtained
63       using dirfd(3).
64
65       The opendir()  function  sets  the  close-on-exec  flag  for  the  file
66       descriptor  underlying  the DIR *.  The fdopendir() function leaves the
67       setting of the close-on-exec flag unchanged for  the  file  descriptor,
68       fd.   POSIX.1-200x  leaves  it unspecified whether a successful call to
69       fdopendir() will set the close-on-exec flag for  the  file  descriptor,
70       fd.
71

SEE ALSO

73       open(2),  closedir(3),  dirfd(3), readdir(3), rewinddir(3), scandir(3),
74       seekdir(3), telldir(3)
75

COLOPHON

77       This page is part of release 3.53 of the Linux  man-pages  project.   A
78       description  of  the project, and information about reporting bugs, can
79       be found at http://www.kernel.org/doc/man-pages/.
80
81
82
83GNU                               2010-06-20                        OPENDIR(3)
Impressum