OSDN Git Service

(split) LDP: Update release pages
[linuxjm/LDP_man-pages.git] / release / man3 / readdir.3
index f89df89..399d747 100644 (file)
@@ -82,12 +82,12 @@ Linux では \fIdirent\fP 構造体は以下のように定義されている。
 .in +4n
 .nf
 struct dirent {
-    ino_t          d_ino;       /* inode number */
-    off_t          d_off;       /* not an offset; see NOTES */
-    unsigned short d_reclen;    /* length of this record */
-    unsigned char  d_type;      /* type of file; not supported
-                                   by all filesystem types */
-    char           d_name[256]; /* filename */
+    ino_t          d_ino;       /* inode 番号 */
+    off_t          d_off;       /* オフセットではない; 注意を参照 */
+    unsigned short d_reclen;    /* このレコードの長さ */
+    unsigned char  d_type;      /* ファイル種別。全ファイルシステム */
+                                   でサポートされているわけではない */
+    char           d_name[256]; /* ファイル名 */
 };
 .fi
 .in
@@ -131,12 +131,9 @@ SVr4, 4.3BSD, POSIX.1\-2001.
 が定義されているかをテストすればよい。
 
 .\" https://lwn.net/Articles/544298/
-The value returned in \fId_off\fP is the same as would be returned by calling
-\fBtelldir\fP(3)  at the current position in the directory stream.  Be aware
-that despite its type and name, the \fId_off\fP field is seldom any kind of
-directory offset on modern filesystems.  Applications should treat this
-field as an opaque value, making no assumptions about its contents; see also
-\fBtelldir\fP(3).
+\fId_off\fP で返される値は \fBtelldir\fP(3) が返す値と同じで、ディレクトリストリーム内の現在の位置を示す。
+フィールドの型や名前はこうなっていますが、最近のファイルシステムでは \fId_off\fP
+フィールドが何らかのディレクトリオフセットであることはめったいにない。アプリケーションプログラムでは、必ずこの値を内容を意識せず単なる値として扱うべきであり、その内容について前提を持つべきではない。
 
 \fId_type\fP フィールドは、Linux 以外では、 主に BSD 系のシステムにだけ存在する。 このフィールドを使うと、
 その後の動作がファイルの種別により決まる場合に、 \fBlstat\fP(2)  を呼び出すコストを避けることができる。 機能検査マクロ
@@ -172,9 +169,9 @@ UNIX ドメインソケットである。
 
 .\" kernel 2.6.27
 .\" The same sentence is in getdents.2
-Currently, only some filesystems (among them: Btrfs, ext2, ext3, and ext4)
-have full support for returning the file type in \fId_type\fP.  All
-applications must properly handle a return of \fBDT_UNKNOWN\fP.
+現在のところ、 \fId_type\fP でファイルタイプを返す機能が完全にサポートされているのは、 いくつかのファイルシステムにおいてのみである
+(Btrfs, ext2, ext3, ext4 はサポートしている)。 どのアプリケーションも、 \fBDT_UNKNOWN\fP
+が返された際に適切に処理できなければならない。
 
 POSIX.1 では \fId_name\fP フィールドのサイズは規定されておらず、 \fIdirent\fP 構造体の \fId_name\fP
 の後ろに他の非標準のフィールドがあるかもしれないので、 移植性が必要なアプリケーションで \fBreaddir_r\fP()  を使う場合は \fIentry\fP