2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
chdir.2, chmod.2, chown.2, gethostname.2, getsid.2, pread.2, setpgid.2, sigaltstack.2, truncate.2, wait.2, dirfd.3, getsubopt.3, mkdtemp.3, mkstemp.3, siginterrupt.3, strdup.3: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-26 15:43:00 +00:00
|
|
|
.TH DIRFD 3 2010-09-26 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
dirfd \- get directory stream file descriptor
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <sys/types.h>
|
|
|
|
.br
|
|
|
|
.B #include <dirent.h>
|
|
|
|
.sp
|
2008-09-23 02:25:35 +00:00
|
|
|
.BI "int dirfd(DIR *" dirp );
|
2007-07-08 12:11:40 +00:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.BR dirfd ():
|
2010-09-17 15:34:00 +00:00
|
|
|
.br
|
|
|
|
.RS 4
|
|
|
|
.PD 0
|
|
|
|
.ad l
|
2007-07-08 12:11:40 +00:00
|
|
|
_BSD_SOURCE || _SVID_SOURCE
|
chdir.2, chmod.2, chown.2, gethostname.2, getsid.2, pread.2, setpgid.2, sigaltstack.2, stat.2, truncate.2, wait.2, dirfd.3, getsubopt.3, mkdtemp.3, mkstemp.3, siginterrupt.3, strdup.3: Simplify feature test macro requirements
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-26 15:16:57 +00:00
|
|
|
.br
|
|
|
|
|| /* Since glibc 2.10: */
|
|
|
|
.RS 4
|
|
|
|
(_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700)
|
|
|
|
.RE
|
2010-09-17 15:34:00 +00:00
|
|
|
.PD
|
|
|
|
.RE
|
|
|
|
.ad
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
The function
|
2005-10-19 07:07:02 +00:00
|
|
|
.BR dirfd ()
|
2004-11-03 13:51:07 +00:00
|
|
|
returns the file descriptor associated with the directory stream
|
2008-09-23 02:25:35 +00:00
|
|
|
.IR dirp .
|
2004-11-03 13:51:07 +00:00
|
|
|
.LP
|
|
|
|
This descriptor is the one used internally by the directory stream.
|
|
|
|
As a result, it is only useful for functions which do not depend on
|
|
|
|
or alter the file position, such as
|
|
|
|
.BR fstat (2)
|
|
|
|
and
|
|
|
|
.BR fchdir (2).
|
|
|
|
It will be automatically closed when
|
|
|
|
.BR closedir (3)
|
|
|
|
is called.
|
2008-07-02 11:25:48 +00:00
|
|
|
.SH RETURN VALUE
|
_syscall.2, accept.2, epoll_create.2, inotify_add_watch.2, ioctl.2, msgget.2, msgop.2, open.2, prctl.2, sched_setscheduler.2, semctl.2, semget.2, swapon.2, addseverity.3, cacosh.3, csqrt.3, dirfd.3, drand48.3, fputws.3, mq_send.3, posix_openpt.3, puts.3, sched_getcpu.3, shm_open.3, sqrt.3, sysconf.3, tgamma.3, ulimit.3, credentials.7, svipc.7: Global fix: s/non-negative/nonnegative/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:44:48 +00:00
|
|
|
On success, a nonnegative file descriptor is returned.
|
2008-07-02 11:25:48 +00:00
|
|
|
On error, \-1 is returned.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH ERRORS
|
2008-08-21 06:08:45 +00:00
|
|
|
POSIX.1-2008 specifies two errors,
|
2008-07-02 11:25:48 +00:00
|
|
|
neither of which is returned by the current
|
|
|
|
.\" glibc 2.8
|
|
|
|
implementation.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
.I dirp
|
|
|
|
does not refer to a valid directory stream.
|
|
|
|
.TP
|
|
|
|
.B ENOTSUP
|
|
|
|
The implementation does not support the association of a file
|
|
|
|
descriptor with a directory.
|
2007-05-19 04:30:20 +00:00
|
|
|
.SH "CONFORMING TO"
|
2008-08-21 06:08:45 +00:00
|
|
|
POSIX.1-2008.
|
|
|
|
This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD.
|
|
|
|
.\" It is present in libc5 (since 5.1.2) and in glibc2.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
|
|
|
The prototype for
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR dirfd ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is only available if
|
|
|
|
.B _BSD_SOURCE
|
|
|
|
or
|
|
|
|
.B _SVID_SOURCE
|
2006-04-21 06:28:54 +00:00
|
|
|
is defined.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR open (2),
|
|
|
|
.BR closedir (3),
|
|
|
|
.BR opendir (3),
|
|
|
|
.BR readdir (3),
|
|
|
|
.BR rewinddir (3),
|
|
|
|
.BR scandir (3),
|
|
|
|
.BR seekdir (3),
|
|
|
|
.BR telldir (3)
|