.\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" 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 2020\-04\-11 Linux "Linux Programmer's Manual" .SH 名前 dirfd \- ディレクトリストリームのファイルディスクリプターを取得する .SH 書式 \fB#include \fP .br \fB#include \fP .PP \fBint dirfd(DIR *\fP\fIdirp\fP\fB);\fP .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBdirfd\fP(): .br .RS 4 .PD 0 .ad l /* glibc 2.10 以降: */ _POSIX_C_SOURCE\ >=\ 200809L || /* glibc 2.19 以前: */ _BSD_SOURCE || _SVID_SOURCE .PD .RE .ad .SH 説明 関数 \fBdirfd\fP() はディレクトリストリーム \fIdirp\fP に関連付けられたファイルディスクリプターを返す。 .PP このファイルディスクリプターはディレクトリストリームが内部で使用するものである。結果的に、この関数が役に立つのは、ファイルの位置に依存しない関数やその位置を変更しない関数 (\fBfstat\fP(2) や \fBfchdir\fP(2) など) においてだけである。このファイルディスクリプターは \fBclosedir\fP(3) が呼ばれたときに自動的にクローズされる。 .SH 返り値 成功すると、 \fBdirfd\fP() はファイルディスクリプター (非負の整数) を返す。エラーの場合、 \-1 が返され、 \fIerrno\fP にエラーの原因を示す値が設定される。 .SH エラー .\" glibc 2.8 POSIX.1\-2008 では 2 つのエラーが規定されている。 現在の実装ではどちらのエラーも返されない。 .TP \fBEINVAL\fP \fIdirp\fP が有効なディレクトリストリームを参照していない。 .TP \fBENOTSUP\fP この実装では、ファイルディスクリプターのディレクトリとの関連付けが サポートされていない。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBdirfd\fP() T} Thread safety MT\-Safe .TE .SH 準拠 .\" It is present in libc5 (since 5.1.2) and in glibc2. POSIX.1\-2008. この関数は BSD 拡張であった。 4.3BSD\-Reno には存在するが、4.2BSD には存在しない。 .SH 関連項目 \fBopen\fP(2), \fBopenat\fP(2), \fBclosedir\fP(3), \fBopendir\fP(3), \fBreaddir\fP(3), \fBrewinddir\fP(3), \fBscandir\fP(3), \fBseekdir\fP(3), \fBtelldir\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。