1DIRFD(3) Linux Programmer's Manual DIRFD(3)
2
3
4
6 dirfd - get directory stream file descriptor
7
9 #include <sys/types.h>
10 #include <dirent.h>
11
12 int dirfd(DIR *dir);
13
15 The function dirfd() returns the file descriptor associated with the
16 directory stream dir.
17
18 This descriptor is the one used internally by the directory stream. As
19 a result, it is only useful for functions which do not depend on or
20 alter the file position, such as fstat(2) and fchdir(2). It will be
21 automatically closed when closedir(3) is called.
22
24 On error -1 is returned.
25
27 The prototype for dirfd() is only available if _BSD_SOURCE or
28 _SVID_SOURCE is defined.
29
31 This is a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD. It is
32 present in libc5 (since 5.1.2) and in glibc2. This function is under
33 consideration for inclusion in a future version of POSIX.1.
34
36 open(2), closedir(3), opendir(3), readdir(3), rewinddir(3), scandir(3),
37 seekdir(3), telldir(3)
38
39
40
41Linux 2.5 2002-01-05 DIRFD(3)