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

NAME

6       dirfd - get directory stream file descriptor
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <dirent.h>
11
12       int dirfd(DIR *dirp);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       dirfd(): _BSD_SOURCE || _SVID_SOURCE
17

DESCRIPTION

19       The  function  dirfd()  returns the file descriptor associated with the
20       directory stream dirp.
21
22       This descriptor is the one used internally by the directory stream.  As
23       a  result,  it  is  only useful for functions which do not depend on or
24       alter the file position, such as fstat(2) and fchdir(2).   It  will  be
25       automatically closed when closedir(3) is called.
26

RETURN VALUE

28       On  success,  a non-negative file descriptor is returned.  On error, -1
29       is returned.
30

ERRORS

32       POSIX.1-2008 specifies two errors, neither of which is returned by  the
33       current implementation.
34
35       EINVAL dirp does not refer to a valid directory stream.
36
37       ENOTSUP
38              The  implementation  does  not support the association of a file
39              descriptor with a directory.
40

CONFORMING TO

42       POSIX.1-2008.  This function was a BSD extension,  present  in  4.3BSD-
43       Reno, not in 4.2BSD.
44

NOTES

46       The   prototype  for  dirfd()  is  only  available  if  _BSD_SOURCE  or
47       _SVID_SOURCE is defined.
48

SEE ALSO

50       open(2), closedir(3), opendir(3), readdir(3), rewinddir(3), scandir(3),
51       seekdir(3), telldir(3)
52

COLOPHON

54       This  page  is  part of release 3.22 of the Linux man-pages project.  A
55       description of the project, and information about reporting  bugs,  can
56       be found at http://www.kernel.org/doc/man-pages/.
57
58
59
60Linux                             2008-08-21                          DIRFD(3)
Impressum