OSDN Git Service

Update release for LDP 3.67
[linuxjm/LDP_man-pages.git] / release / man2 / getdents.2
index a051fc6..16ce713 100644 (file)
@@ -1,5 +1,6 @@
 .\" Copyright (C) 1995 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.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
 .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
 .\"   Derived from 'readdir.2'.
 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
 .\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
 .\"         all rights reserved.
 .\" Translated Sat Feb 22 20:15:56 JST 1997
 .\" Updated Sun Oct 12 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
 .\" Updated Wed Jul 30 JST 2008 by Kentaro Shirakata <argrath@ub32.org>
 .\" Updated 2009-02-12 by Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
 .\"
-.\"WORD:       directory               ¥Ç¥£¥ì¥¯¥È¥ê
-.\"WORD:       entry                   ¥¨¥ó¥È¥ê
-.\"WORD:       memory area             ¥á¥â¥êÎΰè
-.\"WORD:       parameter               ¥Ñ¥é¥á¡¼¥¿¡¼
-.\"WORD:       inode number            inode ÈÖ¹æ
-.\"WORD:       null                    ¥Ì¥ëʸ»ú
-.\"
-.TH GETDENTS 2  2009-07-04 "Linux" "Linux Programmer's Manual"
-.SH Ì¾Á°
-getdents \- ¥Ç¥£¥ì¥¯¥È¥ê¡¦¥¨¥ó¥È¥ê¤ò¼èÆÀ¤¹¤ë
-.SH ½ñ¼°
+.TH GETDENTS 2 2012\-08\-03 Linux "Linux Programmer's Manual"
+.SH 名前
+getdents \- ディレクトリ・エントリを取得する
+.SH 書式
 .nf
-.BI "int getdents(unsigned int " fd ", struct linux_dirent *" dirp ,
-.BI "             unsigned int " count );
+\fBint getdents(unsigned int \fP\fIfd\fP\fB, struct linux_dirent *\fP\fIdirp\fP\fB,\fP
+\fB             unsigned int \fP\fIcount\fP\fB);\fP
 .fi
-.SH ÀâÌÀ
-¤³¤ì¤Ï¤¢¤Ê¤¿¤Î´Ø¿´¤ò°ú¤¯¤è¤¦¤Ê´Ø¿ô¤Ç¤Ï¤Ê¤¤¡£
-POSIX ½àµò¤Î C ¥é¥¤¥Ö¥é¥ê¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë¤Ä¤¤¤Æ¤Ï
-.BR readdir (3)
-¤ò¸«¤ë¤³¤È¡£
-¤³¤Î¥Ú¡¼¥¸¤Ï¡¢¥«¡¼¥Í¥ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÎÀ¸¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë¤Ä¤¤¤Æ
-µ­ºÜ¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
+
+\fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。
+.SH 説明
+これはあなたの関心を引くような関数ではない。 POSIX 準拠の C ライブラリインターフェースについては \fBreaddir\fP(3)  を見ること。
+このページは、カーネルシステムコールの生のインターフェースについて 記載したものである。
 .PP
-.BR getdents ()
-¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¥ª¡¼¥×¥óºÑ¤ß¤Î¥Õ¥¡¥¤¥ëµ­½Ò»Ò
-.I fd
-¤Ç»²¾È¤µ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤«¤é
-.I linux_dirent
-¹½Â¤ÂΤò¤¤¤¯¤Ä¤«Æɤ߽Ф·¡¢
-.I dirp
-¤¬»Ø¤·¤Æ¤¤¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£
-.I count
-°ú¤­¿ô¤Ï¤½¤Î¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤ò¼¨¤¹¡£
+\fBgetdents\fP()  システムコールは、オープン済みのファイルディスクリプタ \fIfd\fP で参照されるディレクトリから
+\fIlinux_dirent\fP 構造体をいくつか読み出し、 \fIdirp\fP が指しているバッファに格納する。 \fIcount\fP
+引き数はそのバッファのサイズを示す。
 .PP
-.I linux_dirent
-¹½Â¤ÂΤϰʲ¼¤Î¤è¤¦¤ËÀë¸À¤µ¤ì¤Æ¤¤¤ë:
+\fIlinux_dirent\fP 構造体は以下のように宣言されている:
 .PP
 .in +4n
 .nf
@@ -76,132 +69,103 @@ struct linux_dirent {
     unsigned long  d_ino;     /* Inode number */
     unsigned long  d_off;     /* Offset to next \fIlinux_dirent\fP */
     unsigned short d_reclen;  /* Length of this \fIlinux_dirent\fP */
-    char           d_name[];  /* Filename (null-terminated) */
-                        /* length is actually (d_reclen \- 2 \-
-                           offsetof(struct linux_dirent, d_name) */
+    char           d_name[];  /* Filename (null\-terminated) */
+                      /* length is actually (d_reclen \- 2 \-
+                         offsetof(struct linux_dirent, d_name)) */
     /*
     char           pad;       // Zero padding byte
-    char           d_type;    // File type (only since Linux 2.6.4;
-                              // offset is (d_reclen \- 1))
+    char           d_type;    // File type (only since Linux
+                              // 2.6.4); offset is (d_reclen \- 1)
     */
 
 }
 .fi
 .in
 .PP
-.I d_ino
-¤Ï inode ÈÖ¹æ¤Ç¤¢¤ë¡£
-.I d_off
-¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤ÎÀèƬ¤«¤é¼¡¤Î
-.I linux_dirent
-¤ÎÀèƬ¤Þ¤Ç¤Îµ÷Î¥¤Ç¤¢¤ë¡£
-.I d_reclen
-¤Ï¤³¤Î
-.I linux_dirent
-Á´ÂΤΥµ¥¤¥º¤Ç¤¢¤ë¡£
-.I d_name
-¤Ï¥Ì¥ë(null)ʸ»ú¤Ç½ª¤ï¤ë¥Õ¥¡¥¤¥ë̾¤Ç¤¢¤ë¡£
+\fId_ino\fP は inode 番号である。 \fId_off\fP はディレクトリの先頭から次の \fIlinux_dirent\fP の先頭までの距離である。
+\fId_reclen\fP はこの \fIlinux_dirent\fP 全体のサイズである。 \fId_name\fP はヌル文字で終わるファイル名である。
 
-.I d_type
-¤Ï¡¢¹½Â¤ÂΤκǸå¤Î¥Ð¥¤¥È¤Ç¤¢¤ê¡¢¥Õ¥¡¥¤¥ë¥¿¥¤¥×¤ò¼¨¤¹¡£
-.I d_type
-¤Ï°Ê²¼¤ÎÃͤΰì¤Ä¤ò¼è¤ë
-.RI ( <dirent.h>
-¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë)¡£
-.TP 12
-.B DT_BLK
-¥Ö¥í¥Ã¥¯¥Ç¥Ð¥¤¥¹¤Ç¤¢¤ë¡£
-.TP
-.B DT_CHR
-¥­¥ã¥é¥¯¥¿¥Ç¥Ð¥¤¥¹¤Ç¤¢¤ë¡£
-.TP
-.B DT_DIR
-¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ë¡£
-.TP
-.B DT_FIFO
-̾Á°¤Ä¤­¥Ñ¥¤¥× (FIFO) ¤Ç¤¢¤ë¡£
-.TP
-.B DT_LNK
-¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ç¤¢¤ë¡£
-.TP
-.B DT_REG
-Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
-.TP
-.B DT_SOCK
-Unix ¥É¥á¥¤¥ó¥½¥±¥Ã¥È¤Ç¤¢¤ë¡£
-.TP
-.B DT_UNKNOWN
-¥Õ¥¡¥¤¥ë¥¿¥¤¥×¤ÏÉÔÌÀ¤Ç¤¢¤ë¡£
+\fId_type\fP は、構造体の最後のバイトであり、ファイルタイプを示す。 \fId_type\fP は以下の値の一つを取る
+(\fI<dirent.h>\fP で定義されている)。
+.TP  12
+\fBDT_BLK\fP
+ブロックデバイスである。
+.TP 
+\fBDT_CHR\fP
+キャラクタデバイスである。
+.TP 
+\fBDT_DIR\fP
+ディレクトリである。
+.TP 
+\fBDT_FIFO\fP
+名前付きパイプ (FIFO) である。
+.TP 
+\fBDT_LNK\fP
+シンボリックリンクである。
+.TP 
+\fBDT_REG\fP
+通常のファイルである。
+.TP 
+\fBDT_SOCK\fP
+UNIX ドメインソケットである。
+.TP 
+\fBDT_UNKNOWN\fP
+ファイルタイプが不明である。
 .PP
-.I d_type
-¥Õ¥£¡¼¥ë¥É¤Ï Linux 2.6.4 ¤«¤é¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
-¤³¤ì¤Ï
-.I linux_dirent
-¹½Â¤ÂΤΤ¦¤Á¡¢°ÊÁ°¤Ï¥¼¥í¤ÇËä¤á¤é¤ì¤Æ¤¤¤¿¶õ´Ö¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¡£
-½¾¤Ã¤Æ¡¢2.6.3 °ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤¹¤ë¤È
-¾ï¤ËÃÍ 0
-.RB ( DT_UNKNOWN )
-¤¬ÊÖ¤µ¤ì¤ë¡£
+\fId_type\fP フィールドは Linux 2.6.4 から実装されている。 これは \fIlinux_dirent\fP
+構造体のうち、以前はゼロで埋められていた空間に配置されている。 従って、2.6.3 以前のカーネルでは、このフィールドにアクセスしようとすると 常に値
+0 (\fBDT_UNKNOWN\fP)  が返される。
 .PP
-¸½ºß¤Î¤È¤³¤í¡¢
-.\" ¥«¡¼¥Í¥ë 2.6.27
-.\" Æ±¤¸ÀâÌÀʸ¤¬ readdir.2 ¤Ë¤â¤¢¤ë¡£
-.I d_type
-¤Ç¥Õ¥¡¥¤¥ë¥¿¥¤¥×¤òÊÖ¤¹µ¡Ç½¤¬´°Á´¤Ë¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢
-¤¤¤¯¤Ä¤«¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ¤Î¤ß¤Ç¤¢¤ë
-(Btrfs, ext2, ext3, ext4 ¤Ï¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë)¡£
-¤É¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤â¡¢
-.B DT_UNKNOWN
-¤¬ÊÖ¤µ¤ì¤¿ºÝ¤ËŬÀڤ˽èÍý¤Ç¤­¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
-.SH ÊÖ¤êÃÍ
-À®¸ù¤·¤¿¾ì¹ç¤Ï¡¢Æɤ߹þ¤ó¤À¥Ð¥¤¥È¿ô¤¬ÊÖ¤µ¤ì¤ë¡£
-¥Ç¥£¥ì¥¯¥È¥ê¤Î½ª¤ï¤ê¤Ê¤é¤Ð 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
-¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤µ¤ì¡¢
-.I errno
-¤ËŬÀÚ¤ÊÃͤ¬ÀßÄꤵ¤ì¤ë¡£
-.SH ¥¨¥é¡¼
-.TP
-.B EBADF
-¥Õ¥¡¥¤¥ëµ­½Ò»Ò
-.I fd
-¤Ï̵¸ú¤Ç¤¢¤ë¡£
-.TP
-.B EFAULT
-°ú¤­¿ô¤¬¡¢¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
-.TP
-.B EINVAL
-·ë²ÌÍѤΥХåե¡¡¼¤¬¾®¤µ¤¹¤®¤ë¡£
-.TP
-.B ENOENT
-¤½¤Î¤è¤¦¤Ê¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸ºß¤·¤Ê¤¤¡£
-.TP
-.B ENOTDIR
-¥Õ¥¡¥¤¥ëµ­½Ò»Ò¤¬¥Ç¥£¥ì¥¯¥È¥ê¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
-.SH ½àµò
+.\" kernel 2.6.27
+.\" The same sentence is in readdir.2
+現在のところ、 \fId_type\fP でファイルタイプを返す機能が完全にサポートされているのは、 いくつかのファイルシステムにおいてのみである
+(Btrfs, ext2, ext3, ext4 はサポートしている)。 どのアプリケーションも、 \fBDT_UNKNOWN\fP
+が返された際に適切に処理できなければならない。
+.SH 返り値
+成功した場合は、読み込んだバイト数が返される。 ディレクトリの終わりならば 0 が返される。 エラーの場合は \-1 を返され、 \fIerrno\fP
+に適切な値が設定される。
+.SH エラー
+.TP 
+\fBEBADF\fP
+ファイルディスクリプタ \fIfd\fP が不正である。
+.TP 
+\fBEFAULT\fP
+引き数が呼び出したプロセスのアドレス空間外を指している。
+.TP 
+\fBEINVAL\fP
+結果用のバッファーが小さすぎる。
+.TP 
+\fBENOENT\fP
+そのようなディレクトリは存在しない。
+.TP 
+\fBENOTDIR\fP
+ファイルディスクリプタがディレクトリを参照していない。
+.SH 準拠
+.\" SVr4 documents additional ENOLINK, EIO error conditions.
 SVr4.
-.\" SVr4 ¤Ç¤Ï¡¢Â¾¤Ë ENOLINK, EIO ¥¨¥é¡¼¾õÂ֤ˤĤ¤¤Æ¤âµ­½Ò¤µ¤ì¤Æ¤¤¤ë¡£
-.SH Ãí°Õ
-glibc ¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÂФ¹¤ë¥é¥Ã¥Ñ¡¼´Ø¿ô¤òÄ󶡤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
-.BR syscall (2)
-¤ò»È¤Ã¤Æ¸Æ¤Ó½Ð¤¹¤³¤È¡£
-.I linux_dirent
-¹½Â¤ÂΤϼ«Ê¬¤ÇÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ë¡£
+.SH 注意
+glibc はこのシステムコールに対するラッパー関数を提供していないので、 \fBsyscall\fP(2)  を使って呼び出すこと。
+\fIlinux_dirent\fP 構造体は自分で定義する必要がある。しかし、たいていはこのシステムコールではなく \fBreaddir\fP(3)
+を使うべき場面のことが多い。
+
+このシステムコールは \fBreaddir\fP(2)  を置き換えるものである。
 
-¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
-.BR readdir (2)
-¤òÃÖ¤­´¹¤¨¤ë¤â¤Î¤Ç¤¢¤ë¡£
-.SH Îã
-²¼µ­¤Î¥×¥í¥°¥é¥à¤Ï
-.BR getdents ()
-¤Î»ÈÍÑÎã¤ò¼¨¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
-°Ê²¼¤Ï¡¢¤³¤Î¥×¥í¥°¥é¥à¤ò ext2 ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¼Â¹Ô¤·¤¿ºÝ¤ËÆÀ¤é¤ì¤ë
-½ÐÎϤÎÎã¤Ç¤¢¤ë¡£
+元々の Linux の \fBgetdents\fP() システムコールは、大きなファイルシステムと
+大きなファイルオフセットを扱うことができなかった。
+その結果、Linux 2.4 で \fBgetdents64\fP() が追加された。
+\fBgetdents64\fP() では、\fIlinux_dirent\fP 構造体のフィールド \fId_ino\fP と
+\fId_off\fP でビット幅の大きなデータ型が使われている。
+.SH 例
+.\" FIXME: This program uses the older getdents() system call
+.\" and the structure with smaller field widths.
+下記のプログラムは \fBgetdents\fP()  の使用例を示したものである。 以下は、このプログラムを ext2 ディレクトリで実行した際に得られる
+出力の例である。
 
 .in +4n
 .nf
-.RB "$" " ./a.out /testfs/"
---------------- nread=120 ---------------
-i-node#  file type  d_reclen  d_off   d_name
+$\fB ./a.out /testfs/\fP
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=120 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
+i\-node#  file type  d_reclen  d_off   d_name
        2  directory    16         12  .
        2  directory    16         24  ..
       11  directory    24         44  lost+found
@@ -211,7 +175,7 @@ i-node#  file type  d_reclen  d_off   d_name
   130817  directory    16       4096  sub3
 .fi
 .in
-.SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
+.SS ã\83\97ã\83­ã\82°ã\83©ã\83 ã\81®ã\82½ã\83¼ã\82¹
 \&
 .nf
 #define _GNU_SOURCE
@@ -223,7 +187,7 @@ i-node#  file type  d_reclen  d_off   d_name
 #include <sys/stat.h>
 #include <sys/syscall.h>
 
-#define handle_error(msg) \\
+#define handle_error(msg) \e
         do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
 struct linux_dirent {
@@ -256,12 +220,12 @@ main(int argc, char *argv[])
         if (nread == 0)
             break;
 
-        printf("\--------------- nread=%d ---------------\\n", nread);
-        printf("i\-node#  file type  d_reclen  d_off   d_name\\n");
+        printf("\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=%d \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\en", nread);
+        printf("i\-node#  file type  d_reclen  d_off   d_name\en");
         for (bpos = 0; bpos < nread;) {
             d = (struct linux_dirent *) (buf + bpos);
             printf("%8ld  ", d\->d_ino);
-            d_type = *(buf + bpos + d\->d_reclen - 1);
+            d_type = *(buf + bpos + d\->d_reclen \- 1);
             printf("%\-10s ", (d_type == DT_REG) ?  "regular" :
                              (d_type == DT_DIR) ?  "directory" :
                              (d_type == DT_FIFO) ? "FIFO" :
@@ -269,8 +233,8 @@ main(int argc, char *argv[])
                              (d_type == DT_LNK) ?  "symlink" :
                              (d_type == DT_BLK) ?  "block dev" :
                              (d_type == DT_CHR) ?  "char dev" : "???");
-            printf("%4d %10lld  %s\\n", d\->d_reclen,
-                    (long long) d\->d_off, (char *) d->d_name);
+            printf("%4d %10lld  %s\en", d\->d_reclen,
+                    (long long) d\->d_off, d\->d_name);
             bpos += d\->d_reclen;
         }
     }
@@ -278,6 +242,9 @@ main(int argc, char *argv[])
     exit(EXIT_SUCCESS);
 }
 .fi
-.SH ´ØÏ¢¹àÌÜ
-.BR readdir (2),
-.BR readdir (3)
+.SH 関連項目
+\fBreaddir\fP(2), \fBreaddir\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。