1opendir(3C)              Standard C Library Functions              opendir(3C)
2
3
4

NAME

6       opendir, fdopendir - open directory
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <dirent.h>
11
12       DIR *opendir(const char *dirname);
13
14
15       DIR *fdopendir(int fildes);
16
17

DESCRIPTION

19       The  opendir()  function  opens a directory stream corresponding to the
20       directory named by the dirname argument.
21
22
23       The fdopendir() function opens a directory  stream  for  the  directory
24       file  descriptor  fildes.  The  directory file descriptor should not be
25       used or closed following a successful  function  call,  as  this  might
26       cause  undefined results from future operations on the directory stream
27       obtained from the call. Use closedir(3C) to close a directory stream.
28
29
30       The directory stream is positioned at the first entry. If the type  DIR
31       is  implemented using a file descriptor, applications will only be able
32       to open up to a total of {OPEN_MAX} files and directories. A successful
33       call to any of the exec functions will close any directory streams that
34       are open in the calling process.  See exec(2).
35

RETURN VALUES

37       Upon successful completion, opendir() and fdopendir() return a  pointer
38       to  an  object  of  type DIR. Otherwise, a null pointer is returned and
39       errno is set to indicate the error.
40

ERRORS

42       The opendir() function will fail if:
43
44       EACCES          Search permission is denied for the  component  of  the
45                       path prefix of dirname or read permission is denied for
46                       dirname.
47
48
49       ELOOP           Too many symbolic links were encountered  in  resolving
50                       path.
51
52
53       ENAMETOOLONG    The  length of the dirname argument exceeds {PATH_MAX},
54                       or a path name  component  is  longer  than  {NAME_MAX}
55                       while {_POSIX_NO_TRUNC} is in effect.
56
57
58       ENOENT          A component of dirname does not name an existing direc‐
59                       tory or dirname is an empty string.
60
61
62       ENOTDIR         A component of dirname is not a directory.
63
64
65
66       The fdopendir() function will fail if:
67
68       ENOTDIR    The file descriptor fildes does not reference a directory.
69
70
71
72       The opendir() function may fail if:
73
74       EMFILE          There are {OPEN_MAX} file descriptors currently open in
75                       the calling process.
76
77
78       ENAMETOOLONG    Pathname  resolution  of  a  symbolic  link produced an
79                       intermediate result whose length exceeds PATH_MAX.
80
81
82       ENFILE          Too many files are currently open on the system.
83
84

USAGE

86       The opendir() and fdopendir() functions should be used  in  conjunction
87       with  readdir(3C),  closedir(3C)  and rewinddir(3C) to examine the con‐
88       tents of the directory (see the EXAMPLES section in readdir(3C)).  This
89       method is recommended for portability.
90

ATTRIBUTES

92       See attributes(5) for descriptions of the following attributes:
93
94
95
96
97       ┌─────────────────────────────┬─────────────────────────────┐
98       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
99       ├─────────────────────────────┼─────────────────────────────┤
100       │Interface Stability          │opendir()    is   Standard;  │
101       │                             │fdopendir() is Evolving      │
102       ├─────────────────────────────┼─────────────────────────────┤
103       │MT-Level                     │Safe                         │
104       └─────────────────────────────┴─────────────────────────────┘
105

SEE ALSO

107       lstat(2), symlink(2), closedir(3C), readdir(3C),  rewinddir(3C),  scan‐
108       dir(3C), attributes(5)
109
110
111
112SunOS 5.11                        26 Jun 2007                      opendir(3C)
Impressum