OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man3 / dirfd.3
1 .\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH DIRFD 3 2008-08-21 "Linux" "Linux Programmer's Manual"
24 .SH NAME
25 dirfd \- get directory stream file descriptor
26 .SH SYNOPSIS
27 .B #include <sys/types.h>
28 .br
29 .B #include <dirent.h>
30 .sp
31 .BI "int dirfd(DIR *" dirp );
32 .sp
33 .in -4n
34 Feature Test Macro Requirements for glibc (see
35 .BR feature_test_macros (7)):
36 .in
37 .sp
38 .BR dirfd ():
39 _BSD_SOURCE || _SVID_SOURCE
40 .SH DESCRIPTION
41 The function
42 .BR dirfd ()
43 returns the file descriptor associated with the directory stream
44 .IR dirp .
45 .LP
46 This descriptor is the one used internally by the directory stream.
47 As a result, it is only useful for functions which do not depend on
48 or alter the file position, such as
49 .BR fstat (2)
50 and
51 .BR fchdir (2).
52 It will be automatically closed when
53 .BR closedir (3)
54 is called.
55 .SH RETURN VALUE
56 On success, a nonnegative file descriptor is returned.
57 On error, \-1 is returned.
58 .SH ERRORS
59 POSIX.1-2008 specifies two errors,
60 neither of which is returned by the current
61 .\" glibc 2.8
62 implementation.
63 .TP
64 .B EINVAL
65 .I dirp
66 does not refer to a valid directory stream.
67 .TP
68 .B ENOTSUP
69 The implementation does not support the association of a file
70 descriptor with a directory.
71 .SH "CONFORMING TO"
72 POSIX.1-2008.
73 This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD.
74 .\" It is present in libc5 (since 5.1.2) and in glibc2.
75 .SH NOTES
76 The prototype for
77 .BR dirfd ()
78 is only available if
79 .B _BSD_SOURCE
80 or
81 .B _SVID_SOURCE
82 is defined.
83 .SH "SEE ALSO"
84 .BR open (2),
85 .BR closedir (3),
86 .BR opendir (3),
87 .BR readdir (3),
88 .BR rewinddir (3),
89 .BR scandir (3),
90 .BR seekdir (3),
91 .BR telldir (3)