1dirfd(3C) Standard C Library Functions dirfd(3C)
2
3
4
6 dirfd - get directory stream file descriptor
7
9 #include <dirent.h>
10
11 int dirfd(DIR *dir);
12
13
15 The dirfd() function returns the file descriptor associated with the
16 directory stream dir.
17
18
19 This file descriptor is the one used internally by the directory stream
20 operations. See opendir(3C), closedir(3C), readdir(3C), rewinddir(3C),
21 seekdir(3C), telldir(3C). The file descriptor is automatically closed
22 when closedir() is called for the directory stream dir or when one of
23 the exec functions is called. See exec(2).
24
25
26 The file descriptor can safely be used only by functions that do not
27 depend on or alter the file position, such as fstat(2) and fchdir(2).
28 Closing the file descriptor with close(2) or modifying the file posi‐
29 tion by means other than the directory stream operations listed above
30 causes undefined behavior to occur when one of the directory stream
31 operations is subsequently called with the directory stream dir.
32
34 Upon successful completion, the dirfd() function returns an open file
35 descriptor for the directory associated with the directory stream dir.
36
38 There are no defined error returns. Passing an invalid directory
39 stream as an argument to the dirfd() function results in undefined
40 behavior.
41
43 The dirfd() function is intended to be used to obtain a file descriptor
44 for use with the fchdir() function.
45
47 See attributes(5) for descriptions of the following attributes:
48
49
50
51
52 ┌─────────────────────────────┬─────────────────────────────┐
53 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
54 ├─────────────────────────────┼─────────────────────────────┤
55 │Interface Stability │Committed │
56 ├─────────────────────────────┼─────────────────────────────┤
57 │MT-Level │Safe │
58 └─────────────────────────────┴─────────────────────────────┘
59
61 close(2), exec(2), fchdir(2), fstat(2), closedir(3C), opendir(3C),
62 readdir(3C), rewinddir(3C), seekdir(3C), telldir(3C), attributes(5)
63
64
65
66SunOS 5.11 24 Oct 2007 dirfd(3C)