Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man3c / dirfd.3c
blob69f1f38cfc7a5c7928283fea7fedf8aba1780452
1 '\" te
2 .\" Copyright (c) 2007, Sun Microsystems Inc. All Rights Reserved.
3 .\" Portions of this manual page are derived from documentation obtained from linuxmanpages.com
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH DIRFD 3C "Oct 24, 2007"
8 .SH NAME
9 dirfd \- get directory stream file descriptor
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <dirent.h>
15 \fBint\fR \fBdirfd\fR(\fBDIR *\fR\fIdir\fR);
16 .fi
18 .SH DESCRIPTION
19 .sp
20 .LP
21 The \fBdirfd()\fR function returns the file descriptor associated with the
22 directory stream \fIdir\fR.
23 .sp
24 .LP
25 This file descriptor is the one used internally by the directory stream
26 operations. See \fBopendir\fR(3C), \fBclosedir\fR(3C), \fBreaddir\fR(3C),
27 \fBrewinddir\fR(3C), \fBseekdir\fR(3C), \fBtelldir\fR(3C).  The file descriptor
28 is automatically closed when \fBclosedir()\fR is called for the directory
29 stream \fIdir\fR or when one of the \fBexec\fR functions is called.  See
30 \fBexec\fR(2).
31 .sp
32 .LP
33 The file descriptor can safely be used only by functions that do not depend on
34 or alter the file position, such as \fBfstat\fR(2) and \fBfchdir\fR(2).
35 Closing the file descriptor with \fBclose\fR(2) or modifying the file position
36 by means other than the directory stream operations listed above causes
37 undefined behavior to occur when one of the directory stream operations is
38 subsequently called with the directory stream \fIdir\fR.
39 .SH RETURN VALUES
40 .sp
41 .LP
42 Upon successful completion, the \fBdirfd()\fR function returns an open file
43 descriptor for the directory associated with the directory stream \fIdir\fR.
44 .SH ERRORS
45 .sp
46 .LP
47 There are no defined error returns.  Passing an invalid directory stream as an
48 argument to the \fBdirfd()\fR function results in undefined behavior.
49 .SH USAGE
50 .sp
51 .LP
52 The \fBdirfd()\fR function is intended to be used to obtain a file descriptor
53 for use with the \fBfchdir()\fR function.
54 .SH ATTRIBUTES
55 .sp
56 .LP
57 See \fBattributes\fR(5) for descriptions of the following attributes:
58 .sp
60 .sp
61 .TS
62 box;
63 c | c
64 l | l .
65 ATTRIBUTE TYPE  ATTRIBUTE VALUE
67 Interface Stability     Committed
69 MT-Level        Safe
70 .TE
72 .SH SEE ALSO
73 .sp
74 .LP
75 \fBclose\fR(2), \fBexec\fR(2), \fBfchdir\fR(2), \fBfstat\fR(2),
76 \fBclosedir\fR(3C), \fBopendir\fR(3C), \fBreaddir\fR(3C), \fBrewinddir\fR(3C),
77 \fBseekdir\fR(3C), \fBtelldir\fR(3C), \fBattributes\fR(5)