]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/dirfd.3
Start of man-pages-5.01: updating Changes and Changes.old
[thirdparty/man-pages.git] / man3 / dirfd.3
CommitLineData
fea681da
MK
1.\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
97986708 25.TH DIRFD 3 2016-03-15 "Linux" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27dirfd \- get directory stream file descriptor
28.SH SYNOPSIS
29.B #include <sys/types.h>
30.br
31.B #include <dirent.h>
68e4db0a 32.PP
3e7a5293 33.BI "int dirfd(DIR *" dirp );
68e4db0a 34.PP
cc4615cc
MK
35.in -4n
36Feature Test Macro Requirements for glibc (see
37.BR feature_test_macros (7)):
38.in
68e4db0a 39.PP
cc4615cc 40.BR dirfd ():
f54c75ef
MK
41.br
42.RS 4
43.PD 0
44.ad l
a30128b4
MK
45/* Since glibc 2.10: */ _POSIX_C_SOURCE\ >=\ 200809L
46 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
f54c75ef
MK
47.PD
48.RE
49.ad
fea681da
MK
50.SH DESCRIPTION
51The function
63aa9df0 52.BR dirfd ()
fea681da 53returns the file descriptor associated with the directory stream
3e7a5293 54.IR dirp .
dd3568a1 55.PP
d9cb0d7d 56This file descriptor is the one used internally by the directory stream.
33a0ccb2 57As a result, it is useful only for functions which do not depend on
fea681da
MK
58or alter the file position, such as
59.BR fstat (2)
60and
61.BR fchdir (2).
62It will be automatically closed when
63.BR closedir (3)
64is called.
155a5e73 65.SH RETURN VALUE
2fda57bd 66On success, a nonnegative file descriptor is returned.
7f1c12c5
MK
67On error, \-1 is returned, and
68.I errno
69is set to indicate the cause of the error.
fea681da 70.SH ERRORS
9f61bba1 71POSIX.1-2008 specifies two errors,
155a5e73
MK
72neither of which is returned by the current
73.\" glibc 2.8
74implementation.
75.TP
76.B EINVAL
77.I dirp
78does not refer to a valid directory stream.
79.TP
80.B ENOTSUP
81The implementation does not support the association of a file
82descriptor with a directory.
70d8c4cb 83.SH ATTRIBUTES
b21d33ae
MK
84For an explanation of the terms used in this section, see
85.BR attributes (7).
86.TS
87allbox;
88lb lb lb
89l l l.
90Interface Attribute Value
91T{
70d8c4cb 92.BR dirfd ()
b21d33ae
MK
93T} Thread safety MT-Safe
94.TE
47297adb 95.SH CONFORMING TO
9f61bba1
MK
96POSIX.1-2008.
97This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD.
98.\" It is present in libc5 (since 5.1.2) and in glibc2.
47297adb 99.SH SEE ALSO
fea681da
MK
100.BR open (2),
101.BR closedir (3),
102.BR opendir (3),
103.BR readdir (3),
104.BR rewinddir (3),
105.BR scandir (3),
106.BR seekdir (3),
107.BR telldir (3)