.\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
.\" Updated 2013-05-04, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.TH WRITE 2 2013\-01\-27 Linux "Linux Programmer's Manual"
+.TH WRITE 2 2014\-05\-04 Linux "Linux Programmer's Manual"
.SH 名前
write \- ファイルディスクリプタ (file descriptor) に書き込む
.SH 書式
で \fBopen\fP(2) された場合、ファイルオフセットは書き込み前に ファイルの末尾に設定される。
ファイルオフセットの調整と書き込み操作はアトミックな処理として 実行される。
-POSIX requires that a \fBread\fP(2) which can be proved to occur after a
-\fBwrite\fP() has returned returns the new data. Note that not all
-filesystems are POSIX conforming.
+POSIX は \fBwrite\fP() が行なわれた後に実行した \fBread\fP(2) が 新しいデータを返すことを要求している。
+全てのファイルシステムが POSIX 準拠ではない点に注意すること。
.SH 返り値
成功した場合、書き込まれたバイト数が返される (ゼロは何も書き込まれなかったことを示す)。 エラーならば \-1 が返され、\fIerrno\fP
が適切に設定される。
\fIfd\fP が、 \fBconnect\fP(2) を使って通信相手のアドレスが設定されていないデータグラムソケットを 参照している。
.TP
\fBEDQUOT\fP
-The user's quota of disk blocks on the filesystem containing the file
-referred to by \fIfd\fP has been exhausted.
+\fIfd\fP が参照するファイルを含むファイルシステムのディスクブロックのユーザクォータの上限に達している。
.TP
\fBEFAULT\fP
\fIbuf\fP がアクセス可能なアドレス空間の外にある。
\fBwrite\fP() が 1 バイトも書き込まないうちにシグナルハンドラにより割り込まれた場合、 \fBwrite\fP() はエラー \fBEINTR\fP
で失敗する。 1バイトでも書き込んだ後で割り込まれた場合には、 \fBwrite\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 \fBwrite\fP() and \fBwritev\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 \fBwrite\fP() (or \fBwritev\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 blocks of data output by the two processes might
+(incorrectly) overlap. This problem was fixed in Linux 3.14.
.SH 関連項目
\fBclose\fP(2), \fBfcntl\fP(2), \fBfsync\fP(2), \fBioctl\fP(2), \fBlseek\fP(2), \fBopen\fP(2),
\fBpwrite\fP(2), \fBread\fP(2), \fBselect\fP(2), \fBwritev\fP(2), \fBfwrite\fP(3)
.SH この文書について
-この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.54 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
である。プロジェクトの説明とバグ報告に関する情報は
http://www.kernel.org/doc/man\-pages/ に書かれている。