OSDN Git Service

Update releases for LDP 3.68
[linuxjm/LDP_man-pages.git] / release / man2 / read.2
index 38b80a3..a7065c7 100644 (file)
@@ -1,8 +1,7 @@
-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
-.\"                               1993 Michael Haardt, Ian Jackson.
+.\"             and Copyright (C) 1993 Michael Haardt, Ian Jackson.
 .\"
 .\"
+.\" %%%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 make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -22,6 +21,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" Modified Sat Jul 24 00:06:00 1993 by Rik Faith <faith@cs.unc.edu>
 .\" Modified Wed Jan 17 16:02:32 1996 by Michael Haardt
 .\"
 .\" Modified Sat Jul 24 00:06:00 1993 by Rik Faith <faith@cs.unc.edu>
 .\" Modified Wed Jan 17 16:02:32 1996 by Michael Haardt
 .\" This file was generated with po4a. Translate the source file.
 .\"
 .\"*******************************************************************
 .\" This file was generated with po4a. Translate the source file.
 .\"
 .\"*******************************************************************
-.TH READ 2 2009\-02\-23 Linux "Linux Programmer's Manual"
+.\"
+.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
+.\"         all rights reserved.
+.\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Modified 1997-09-28, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated & Modified 2005-02-24, Yuichi SATO <ysato444@yahoo.co.jp>
+.\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2005-10-14, Akihiro MOTOKI
+.\" Updated 2008-02-10, Akihiro MOTOKI, LDP v2.77
+.\" Updated 2009-04-13, Akihiro MOTOKI, LDP v3.20
+.\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
+.TH READ 2 2014\-05\-04 Linux "Linux Programmer's Manual"
 .SH 名前
 read \- ファイルディスクリプタから読み込む
 .SH 書式
 .SH 名前
 read \- ファイルディスクリプタから読み込む
 .SH 書式
@@ -49,9 +62,15 @@ read \- ファイルディスクリプタから読み込む
 .SH 説明
 \fBread\fP()  はファイルディスクリプタ (file descriptor)  \fIfd\fP から最大 \fIcount\fP バイトを \fIbuf\fP
 で始まるバッファーへ読み込もうとする。
 .SH 説明
 \fBread\fP()  はファイルディスクリプタ (file descriptor)  \fIfd\fP から最大 \fIcount\fP バイトを \fIbuf\fP
 で始まるバッファーへ読み込もうとする。
-.PP
-\fIcount\fP が 0 ならば、 \fBread\fP()  は 0 を返し、他に何も起きない。 \fIcount\fP が \fBSSIZE_MAX\fP
-より大きければ、結果は特定できない。
+
+seek に対応しているファイルでは、read
+は現在のファイルオフセットから行われ、ファイルオフセットは読み込んだバイト数分だけ進められる。現在のファイルオフセットがファイル末尾かそれより先の場合は、読み出しは行われず、
+\fBread\fP() は 0 を返す。
+
+\fIcount\fP が 0 の場合、 \fBread\fP() は以下で説明するエラーを検出する\fI場合がある\fP。 どのエラーもなかった場合、もしくは
+\fBread\fP() がエラーのチェックを行わない場合、 \fIcount\fP が 0 で呼び出された \fBread\fP() は 0 を返し、何も行わない。
+
+\fIcount\fP が \fBSSIZE_MAX\fP より大きければ、結果は規定できない。
 .SH 返り値
 成功した場合、読み込んだバイト数を返す (0 はファイルの終りを意味する)。 ファイル位置はこの数だけ進められる。
 この数が要求した数より小さかったとしてもエラーではない; 例えば今すぐには実際にそれだけの数しかない場合 (ファイルの最後に近いのかも
 .SH 返り値
 成功した場合、読み込んだバイト数を返す (0 はファイルの終りを意味する)。 ファイル位置はこの数だけ進められる。
 この数が要求した数より小さかったとしてもエラーではない; 例えば今すぐには実際にそれだけの数しかない場合 (ファイルの最後に近いのかも
@@ -88,8 +107,8 @@ read \- ファイルディスクリプタから読み込む
 さらなる情報は \fBtimerfd_create\fP(2)  を参照のこと。
 .TP 
 \fBEIO\fP
 さらなる情報は \fBtimerfd_create\fP(2)  を参照のこと。
 .TP 
 \fBEIO\fP
-I/O エラー。これは例えばプロセスがバックグランド・プロセスグループで、 それを制御している tty から読み込もうとし、 \fBSIGTTIN\fP
-が無視 (ignore) または禁止 (blocking) されている場合や、 そのプロセスグループが孤立 (orphan) している場合に起こる。
+I/O エラー。これは例えばプロセスがバックグランド・プロセスグループで、それを制御している端末から読み込もうとし、 \fBSIGTTIN\fP が無視
+(ignore) または禁止 (blocking) されている場合や、 そのプロセスグループが孤立 (orphan) している場合に起こる。
 またディスクやテープを読んでいる時に低レベル I/O エラー が発生した場合にも起こる。
 .TP 
 \fBEISDIR\fP
 またディスクやテープを読んでいる時に低レベル I/O エラー が発生した場合にも起こる。
 .TP 
 \fBEISDIR\fP
@@ -105,10 +124,40 @@ NFS において。少量のデータを読み込む場合、最初の時のみ
 (最終ファイルアクセス時刻)  の更新をサーバーに送らず、クライアント側でキャッシュを読むことに満足して いれば、サーバー側での read
 は発生しないので st_atime の更新は行なわれからだ。 UNIX の方式では、クライアント側の属性のキャッシングを無効にすることで、
 これを得ることができる。しかしほとんどの状況ではこれは続くサーバーの 負荷を増加させ、パフォーマンスの低下をもたらす。
 (最終ファイルアクセス時刻)  の更新をサーバーに送らず、クライアント側でキャッシュを読むことに満足して いれば、サーバー側での read
 は発生しないので st_atime の更新は行なわれからだ。 UNIX の方式では、クライアント側の属性のキャッシングを無効にすることで、
 これを得ることができる。しかしほとんどの状況ではこれは続くサーバーの 負荷を増加させ、パフォーマンスの低下をもたらす。
-.PP
-多くのファイルシステムやディスクは \fBO_NONBLOCK\fP の実装はしなくても済むくらいに十分に高速であると考えられている。
-それでそのようなファイルやディスクには \fBO_NONBLOCK\fP は利用できないかもしれない。
+.SH バグ
+According to POSIX.1\-2008/SUSv4 Section XSI 2.9.7 ("Thread Interactions with
+Regular File Operations"):
+
+.RS 4
+All of the following functions shall be atomic with respect to each other in
+the effects specified in POSIX.1\-2008 when they operate on regular files or
+symbolic links: ...
+.RE
+
+.\" http://thread.gmane.org/gmane.linux.kernel/1649458
+.\"    From: Michael Kerrisk (man-pages <mtk.manpages <at> gmail.com>
+.\"    Subject: Update of file offset on write() etc. is non-atomic with I/O
+.\"    Date: 2014-02-17 15:41:37 GMT
+.\"    Newsgroups: gmane.linux.kernel, gmane.linux.file-systems
+.\" commit 9c225f2655e36a470c4f58dbbc99244c5fc7f2d4
+.\"    Author: Linus Torvalds <torvalds@linux-foundation.org>
+.\"    Date:   Mon Mar 3 09:36:58 2014 -0800
+.\"
+.\"        vfs: atomic f_pos accesses as per POSIX
+Among the APIs subsequently listed are \fBread\fP()  and \fBreadv\fP(2).  And
+among the effects that should be atomic across threads (and processes)  are
+updates of the file offset.  However, on Linux before version 3.14, this was
+not the case: if two processes that share an open file description (see
+\fBopen\fP(2))  perform a \fBread\fP()  (or \fBreadv\fP(2))  at the same time, then
+the I/O operations were not atomic with respect updating the file offset,
+with the result that the reads in the two processes might (incorrectly)
+overlap in the blocks of data that they obtained.  This problem was fixed in
+Linux 3.14.
 .SH 関連項目
 \fBclose\fP(2), \fBfcntl\fP(2), \fBioctl\fP(2), \fBlseek\fP(2), \fBopen\fP(2), \fBpread\fP(2),
 \fBreaddir\fP(2), \fBreadlink\fP(2), \fBreadv\fP(2), \fBselect\fP(2), \fBwrite\fP(2),
 \fBfread\fP(3)
 .SH 関連項目
 \fBclose\fP(2), \fBfcntl\fP(2), \fBioctl\fP(2), \fBlseek\fP(2), \fBopen\fP(2), \fBpread\fP(2),
 \fBreaddir\fP(2), \fBreadlink\fP(2), \fBreadv\fP(2), \fBselect\fP(2), \fBwrite\fP(2),
 \fBfread\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.68 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。