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

DESCRIPTION

16       The  opendir()  function  opens a directory stream corresponding to the
17       directory name, and returns a pointer to  the  directory  stream.   The
18       stream is positioned at the first entry in the directory.
19
20       The  fdopendir()  is like opendir(), but returns a directory stream for
21       the directory referred to by the open file descriptor fd.  After a suc‐
22       cessful  call  to fdopendir(), fd is used internally by the implementa‐
23       tion, and should not otherwise be used by the application.
24

RETURN VALUE

26       The opendir() and fdopendir() functions return a pointer to the  direc‐
27       tory  stream.   On  error, NULL is returned, and errno is set appropri‐
28       ately.
29

ERRORS

31       EACCES Permission denied.
32
33       EBADF  fd is not a valid file descriptor opened for reading.
34
35       EMFILE Too many file descriptors in use by process.
36
37       ENFILE Too many files are currently open in the system.
38
39       ENOENT Directory does not exist, or name is an empty string.
40
41       ENOMEM Insufficient memory to complete the operation.
42
43       ENOTDIR
44              name is not a directory.
45

VERSIONS

47       fdopendir() is available in glibc since version 2.4.
48

CONFORMING TO

50       opendir() is present on SVr4, 4.3BSD, and  specified  in  POSIX.1-2001.
51       fdopendir() is specified in POSIX.1-2008.
52

NOTES

54       The  underlying file descriptor of the directory stream can be obtained
55       using dirfd(3).
56
57       The opendir()  function  sets  the  close-on-exec  flag  for  the  file
58       descriptor  underlying  the DIR *.  The fdopendir() function leaves the
59       setting of the close-on-exec flag unchanged for  the  file  descriptor,
60       fd.   POSIX.1-200x  leaves  it unspecified whether a successful call to
61       fdopendir() will set the close-on-exec flag for  the  file  descriptor,
62       fd.
63

SEE ALSO

65       open(2),  closedir(3),  dirfd(3), readdir(3), rewinddir(3), scandir(3),
66       seekdir(3), telldir(3)
67

COLOPHON

69       This page is part of release 3.22 of the Linux  man-pages  project.   A
70       description  of  the project, and information about reporting bugs, can
71       be found at http://www.kernel.org/doc/man-pages/.
72
73
74
75GNU                               2008-08-06                        OPENDIR(3)
Impressum