.\" 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. .\" .\" 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. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" .\" Japanese Version Copyright (c) 2002-2003 Yuichi SATO .\" all rights reserved. .\" Translated Mon May 6 21:32:36 JST 2002 .\" by Yuichi SATO .\" Updated & Modified Sun Sep 7 01:23:08 JST 2003 .\" by Yuichi SATO .\" .TH DIRFD 3 2010-09-26 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O dirfd \- get directory stream file descriptor dirfd \- ディレクトリ・ストリームのファイル・ディスクリプタを取得する .\"O .SH SYNOPSIS .SH 書式 .B #include .br .B #include .sp .BI "int dirfd(DIR *" dirp ); .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR dirfd (): .br .RS 4 .PD 0 .ad l _BSD_SOURCE || _SVID_SOURCE .br .\"O || /* Since glibc 2.10: */ || /* glibc 2.10 以降: */ .RS 4 (_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700) .RE .PD .RE .ad .\"O .SH DESCRIPTION .SH 説明 .\"O The function .\"O .BR dirfd () .\"O returns the file descriptor associated with the directory stream .\"O .IR dirp . 関数 .BR dirfd () はディレクトリ・ストリーム .I dirp に関連づけられたファイル・ディスクリプタを返す。 .LP .\"O This descriptor is the one used internally by the directory stream. このディスクリプタはディレクトリ・ストリームが内部で使用するものである。 .\"O As a result, it is only useful for functions which do not depend on .\"O or alter the file position, such as .\"O .BR fstat (2) .\"O and .\"O .BR fchdir (2). よって、ファイルの位置に依存せず、かつその位置を変更しない関数 .BR fstat (2) や .BR fchdir (2) などでしか役に立たない。 .\"O It will be automatically closed when .\"O .BR closedir (3) .\"O is called. このディスクリプタは .BR closedir (3) が呼ばれたときに自動的にクローズされる。 .\"O .SH RETURN VALUE .SH 返り値 .\"O On success, a nonnegative file descriptor is returned. .\"O On error, \-1 is returned. 成功すると、負でない値のファイルディスクリプタが返される。 エラーの場合は \-1 が返される。 .\"O .SH ERRORS .SH エラー .\"O POSIX.1-2008 specifies two errors, .\"O neither of which is returned by the current .\"O .\" glibc 2.8 .\"O implementation. POSIX.1-2008 では 2 つのエラーが規定されている。 現在の実装ではどちらのエラーも返されない。 .\" glibc 2.8 .TP .B EINVAL .\"O .I dirp .\"O does not refer to a valid directory stream. .I dirp が有効なディレクトリ・ストリームを参照していない。 .TP .B ENOTSUP .\"O The implementation does not support the association of a file .\"O descriptor with a directory. この実装では、ファイルディスクリプタのディレクトリとの関連付けが サポートされていない。 .\"O .SH "CONFORMING TO" .SH 準拠 POSIX.1-2008. .\"O This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD. .\"O .\" It is present in libc5 (since 5.1.2) and in glibc2. この関数は BSD 拡張であった。 4.3BSD-Reno には存在するが、4.2BSD には存在しない。 .\" libc5 (5.1.2 以降) と glibc2 に存在する。 .\"O .SH NOTES .SH 注意 .\"O The prototype for .\"O .BR dirfd () .\"O is only available if .\"O .B _BSD_SOURCE .\"O or .\"O .B _SVID_SOURCE .\"O is defined. .BR dirfd () のプロトタイプが使用可能なのは、 .B _BSD_SOURCE または .B _SVID_SOURCE が定義されたときのみである。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR open (2), .BR closedir (3), .BR opendir (3), .BR readdir (3), .BR rewinddir (3), .BR scandir (3), .BR seekdir (3), .BR telldir (3)