1 .\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .TH DIRFD 3 2010-09-26 "Linux" "Linux Programmer's Manual"
25 dirfd \- get directory stream file descriptor
27 .B #include <sys/types.h>
29 .B #include <dirent.h>
31 .BI "int dirfd(DIR *" dirp );
34 Feature Test Macro Requirements for glibc (see
35 .BR feature_test_macros (7)):
43 _BSD_SOURCE || _SVID_SOURCE
45 || /* Since glibc 2.10: */
47 (_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700)
55 returns the file descriptor associated with the directory stream
58 This descriptor is the one used internally by the directory stream.
59 As a result, it is only useful for functions which do not depend on
60 or alter the file position, such as
64 It will be automatically closed when
68 On success, a nonnegative file descriptor is returned.
69 On error, \-1 is returned.
71 POSIX.1-2008 specifies two errors,
72 neither of which is returned by the current
78 does not refer to a valid directory stream.
81 The implementation does not support the association of a file
82 descriptor with a directory.
85 This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD.
86 .\" It is present in libc5 (since 5.1.2) and in glibc2.