]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/dirfd.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / dirfd.3
CommitLineData
fea681da
MK
1.\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da 4.\"
45186a5d 5.TH DIRFD 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
6.SH NAME
7dirfd \- get directory stream file descriptor
b813014f
AC
8.SH LIBRARY
9Standard C library
10.RI ( libc ", " \-lc )
fea681da 11.SH SYNOPSIS
c7db92b9 12.nf
fea681da 13.B #include <sys/types.h>
fea681da 14.B #include <dirent.h>
68e4db0a 15.PP
3e7a5293 16.BI "int dirfd(DIR *" dirp );
c7db92b9 17.fi
68e4db0a 18.PP
d39ad78f 19.RS -4
cc4615cc
MK
20Feature Test Macro Requirements for glibc (see
21.BR feature_test_macros (7)):
d39ad78f 22.RE
68e4db0a 23.PP
cc4615cc 24.BR dirfd ():
9d2adbae 25.nf
5c10d2c5 26 /* Since glibc 2.10: */ _POSIX_C_SOURCE >= 200809L
9d2adbae
MK
27 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
28.fi
fea681da
MK
29.SH DESCRIPTION
30The function
63aa9df0 31.BR dirfd ()
fea681da 32returns the file descriptor associated with the directory stream
3e7a5293 33.IR dirp .
dd3568a1 34.PP
d9cb0d7d 35This file descriptor is the one used internally by the directory stream.
33a0ccb2 36As a result, it is useful only for functions which do not depend on
fea681da
MK
37or alter the file position, such as
38.BR fstat (2)
39and
40.BR fchdir (2).
41It will be automatically closed when
42.BR closedir (3)
43is called.
155a5e73 44.SH RETURN VALUE
ed09120a
MK
45On success,
46.BR dirfd ()
47returns a file descriptor (a nonnegative integer).
7f1c12c5
MK
48On error, \-1 is returned, and
49.I errno
855d489a 50is set to indicate the error.
fea681da 51.SH ERRORS
9f61bba1 52POSIX.1-2008 specifies two errors,
155a5e73
MK
53neither of which is returned by the current
54.\" glibc 2.8
55implementation.
56.TP
57.B EINVAL
58.I dirp
59does not refer to a valid directory stream.
60.TP
61.B ENOTSUP
62The implementation does not support the association of a file
63descriptor with a directory.
70d8c4cb 64.SH ATTRIBUTES
b21d33ae
MK
65For an explanation of the terms used in this section, see
66.BR attributes (7).
c466875e
MK
67.ad l
68.nh
b21d33ae
MK
69.TS
70allbox;
c466875e 71lbx lb lb
b21d33ae
MK
72l l l.
73Interface Attribute Value
74T{
70d8c4cb 75.BR dirfd ()
b21d33ae
MK
76T} Thread safety MT-Safe
77.TE
c466875e
MK
78.hy
79.ad
80.sp 1
3113c7f3 81.SH STANDARDS
9f61bba1
MK
82POSIX.1-2008.
83This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD.
84.\" It is present in libc5 (since 5.1.2) and in glibc2.
47297adb 85.SH SEE ALSO
fea681da 86.BR open (2),
7022462f 87.BR openat (2),
fea681da
MK
88.BR closedir (3),
89.BR opendir (3),
90.BR readdir (3),
91.BR rewinddir (3),
92.BR scandir (3),
93.BR seekdir (3),
94.BR telldir (3)