OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / release / man3 / readdir.3
index 580062a..6955c6a 100644 (file)
@@ -1,5 +1,6 @@
 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
 .\"
+.\" %%%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.
@@ -19,6 +20,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" References consulted:
 .\"     Linux libc source code
@@ -36,7 +38,7 @@
 .\" This file was generated with po4a. Translate the source file.
 .\"
 .\"*******************************************************************
-.TH READDIR 3 2010\-09\-10 "" "Linux Programmer's Manual"
+.TH READDIR 3 2013\-06\-21 "" "Linux Programmer's Manual"
 .SH 名前
 readdir, readdir_r \- ディレクトリを読み込む
 .SH 書式
@@ -69,7 +71,7 @@ Linux では \fIdirent\fP 構造体は以下のように定義されている。
 .nf
 struct dirent {
     ino_t          d_ino;       /* inode 番号 */
-    off_t          d_off;       /* 次の dirent へのオフセット */
+    off_t          d_off;       /* オフセットではない; 注意を参照 */
     unsigned short d_reclen;    /* このレコードの長さ */
     unsigned char  d_type;      /* ファイル種別。全ファイルシステム */
                                    でサポートされているわけではない */
@@ -80,7 +82,8 @@ struct dirent {
 .PP
 \fIdirent\fP 構造体のフィールドで POSIX.1 で要求されているのは、 \fId_name\fP[] と (XSI 拡張での)  \fId_ino\fP
 だけである。 \fId_name\fP[] はその大きさも規定されておらず、 このフィールドには最大で \fBNAME_MAX\fP 個の文字と、それに続く終端の
-NULL バイトが格納される。 他のフィールドは非標準であり、全てのシステムに存在するわけではない。 詳細については、下記の「注意」を参照のこと。
+NULL バイト (\(aq\e0\(aq)が格納される。 他のフィールドは非標準であり、全てのシステムに存在するわけではない。
+詳細については、下記の「注意」を参照のこと。
 .PP
 \fBreaddir\fP()  によって返されるデータは、それ以降の同じストリームに対する \fBreaddir\fP()
 の呼び出しによって上書きされる可能性がある。
@@ -101,6 +104,11 @@ NULL バイトが格納される。 他のフィールドは非標準であり
 .TP 
 \fBEBADF\fP
 ディレクトリストリームディスクリプタ \fIdirp\fP が無効である。
+.SH 属性
+.SS "マルチスレッディング (pthreads(7) 参照)"
+\fBreaddir\fP() 関数はスレッドセーフではない。
+.LP
+\fBreaddir_r\fP() 関数はスレッドセーフである。
 .SH 準拠
 SVr4, 4.3BSD, POSIX.1\-2001.
 .SH 注意
@@ -110,6 +118,11 @@ SVr4, 4.3BSD, POSIX.1\-2001.
 \fB_DIRENT_HAVE_D_RECLEN\fP, \fB_DIRENT_HAVE_D_OFF\fP, \fB_DIRENT_HAVE_D_TYPE\fP
 が定義されているかをテストすればよい。
 
+.\" https://lwn.net/Articles/544298/
+\fId_off\fP で返される値は \fBtelldir\fP(3) が返す値と同じで、ディレクトリストリーム内の現在の位置を示す。
+フィールドの型や名前はこうなっていますが、最近のファイルシステムでは \fId_off\fP
+フィールドが何らかのディレクトリオフセットであることはめったいにない。アプリケーションプログラムでは、必ずこの値を内容を意識せず単なる値として扱うべきであり、その内容について前提を持つべきではない。
+
 \fId_type\fP フィールドは、Linux 以外では、 主に BSD 系のシステムにだけ存在する。 このフィールドを使うと、
 その後の動作がファイルの種別により決まる場合に、 \fBlstat\fP(2)  を呼び出すコストを避けることができる。 機能検査マクロ
 \fB_BSD_SOURCE\fP が定義された場合、glibc は \fId_type\fP で返される値として以下のマクロ定数を定義する。
@@ -154,8 +167,10 @@ POSIX.1 では \fId_name\fP フィールドのサイズは規定されておら
 .in +4n
 .nf
 
-len = offsetof(struct dirent, d_name) +
-          pathconf(dirpath, _PC_NAME_MAX) + 1
+name_max = pathconf(dirpath, _PC_NAME_MAX);
+if (name_max == \-1)         /* 上限が定義されていない、またはエラー */
+    name_max = 255;         /* 適当な値を入れる */
+len = offsetof(struct dirent, d_name) + name_max + 1;
 entryp = malloc(len);
 
 .fi
@@ -166,6 +181,6 @@ entryp = malloc(len);
 \fBoffsetof\fP(3), \fBopendir\fP(3), \fBrewinddir\fP(3), \fBscandir\fP(3),
 \fBseekdir\fP(3), \fBtelldir\fP(3)
 .SH この文書について
-この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
 である。プロジェクトの説明とバグ報告に関する情報は
 http://www.kernel.org/doc/man\-pages/ に書かれている。