.\" Copyright (C) 2008, 2016 Michael Kerrisk .\" and Copyright (C) 2016 Florian Weimer .\" .\" %%%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. .\" .\"******************************************************************* .TH READDIR_R 3 2016\-03\-01 "" "Linux Programmer's Manual" .SH 名前 readdir_r \- ディレクトリを読み込む .SH 書式 .nf \fB#include \fP .PP \fBint readdir_r(DIR *\fP\fIdirp\fP\fB, struct dirent *\fP\fIentry\fP\fB, struct dirent **\fP\fIresult\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .ad l .RE .PP \fBreaddir_r\fP(): .RS 4 _POSIX_C_SOURCE || /* glibc 2.19 以前: */ _BSD_SOURCE || _SVID_SOURCE .RE .ad b .SH 説明 この関数は非推奨である。代わりに \fBreaddir\fP(3) を使用すること。 .PP \fBreaddir_r\fP() 関数は \fBreaddir\fP(3) のリエントラント版として導入された。この関数はディレクトリストリーム \fIdirp\fP から次のディレクトリエントリーを読み込み、 \fIentry\fP が指す呼び出し元が割り当てたバッファーにそのエントリーを格納して返す。 \fIdirent\fP 構造体の詳細は \fBreaddir\fP(3) を参照。 .PP 結果を返すバッファへのポインターが \fI*result\fP に格納される。ディレクトリストリームの末尾に達した場合は、NULL が代わりに \fI*result\fP で返される。 .PP アプリケーションでは \fBreaddir_r\fP() の代わりに \fBreaddir\fP(3) を使用することを推奨する。さらに、glibc 2.24 以降では \fBreaddir_r\fP() は非推奨となっている。理由は以下の通りである。 .IP * 3 \fBNAME_MAX\fP が未定義のシステムでは、 \fBreaddir_r\fP() の呼び出しは安全ではない。このインターフェースでは、呼び出し元がディレクトリエントリーを返す際に使用されるバッファの長さを指定することができないからである。 .IP * いくつかのシステムでは、 \fBreaddir_r\fP() は非常に長い名前のディレクトリエントリーを読み込むことができない。 glibc の実装ではこのような名前に遭遇した場合、 \fBreaddir_r\fP() は \fI最後のディレクトリエントリーを読み込んだ後\fP エラー \fBENAMETOOLONG\fP で失敗する。他のいくつかのシステムでは、 \fBreaddir_r\fP() が成功ステータスを返しても、返された \fId_name\fP フィールドがヌル終端されていなかったり、文字列が途中までで切り詰められていたりすることがある。 .IP * 現在の POSIX.1 標準 (POSIX.1\-2008) では、 \fBreaddir\fP(3) がスレッドセーフであることは求められていない。しかしながら、最近の実装 (glibc による実装も含む) では、異なるディレクトリストリームに対する \fBreaddir\fP(3) の同時並行の呼び出しはスレッドセーフである。したがって、マルチスレッドプログラムにおいて \fBreaddir_r\fP() の使用は不要である。複数のスレッドが同じディレクトリストリームから読み込みを行う必要がある場合も、上記で挙げた理由から、非推奨の \fBreaddir_r\fP() 関数を使用するよりも、外部同期を用いた \fBreaddir\fP(3) を使う方が推奨される。 .IP * .\" FIXME . .\" http://www.austingroupbugs.net/view.php?id=696 POSIX.1 の将来のバージョンでは、 \fBreaddir_r\fP() は廃止予定 (obsolete) となり、 \fBreaddir\fP(3) は異なるディレクトリストリームに対して同時に使用された際にスレッドセーフであることが必須となる予定である。 .SH 返り値 成功すると、 \fBreaddir_r\fP() 関数は 0 を返す。 エラーの場合、(「エラー」の節のリストに載っている) 正のエラー番号を返す。 ディレクトリストリームの末尾に達した場合、 \fBreaddir_r\fP() は返り値として 0 を返し、 \fI*result\fP に NULL を格納する。 .SH エラー .TP \fBEBADF\fP ディレクトリストリームディスクリプター \fIdirp\fP が無効である。 .TP \fBENAMETOOLONG\fP 読み込むには名前が長過ぎるディレクトリエントリーに遭遇した。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBreaddir_r\fP() T} Thread safety MT\-Safe .TE .SH 準拠 POSIX.1\-2001, POSIX.1\-2008. .SH 関連項目 \fBreaddir\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。