.\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
.\" Updated 2013-08-16, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.TH OPEN 2 2014\-05\-10 Linux "Linux Programmer's Manual"
+.TH OPEN 2 2014\-10\-02 Linux "Linux Programmer's Manual"
.SH 名前
open, openat, creat \- ファイルのオープン、作成を行う
.SH 書式
.PP
デフォルトでは、新しいファイルディスクリプタは \fBexecve\fP(2) を実行した後も
オープンされたままとなる (つまり、 \fBfcntl\fP(2) に説明がある \fBFD_CLOEXEC\fP
-ファイルディスクリプタフラグは最初は無効である; 後述の \fBO_CLOEXEC\fP フラグ
-を使うとこのデフォルトを変更することができる)。 ファイルオフセット
+ファイルディスクリプタフラグは最初は無効である); 後述の \fBO_CLOEXEC\fP フラグ
+を使うとこのデフォルトを変更することができる。 ファイルオフセット
(file offset) はファイルの先頭に設定される (\fBlseek\fP(2) 参照)。
.PP
A call to \fBopen\fP() creates a new \fIopen file description\fP, an entry in the
-system\-wide table of open files. (This object is variously also called an
-"open file object", a "file handle", an "open file table entry", or\(emin
-kernel\-developer parlance\(ema \fIstruct file\fP. The term "open file
-description" is used by POSIX.) The open file description records the file
+system\-wide table of open files. The open file description records the file
offset and the file status flags (see below). A file descriptor is a
reference to an open file description; this reference is unaffected if
\fIpathname\fP is subsequently removed or modified to refer to a different
-file. The new open file description is initially not shared with any other
-process, but sharing may arise via \fBfork\fP(2).
+file. For further details on open file descriptions, see NOTES.
.PP
引き数 \fIflags\fP には、アクセスモード \fBO_RDONLY\fP, \fBO_WRONLY\fP, \fBO_RDWR\fP
のどれかひとつが入っていなければならない。 これらはそれぞれ読み込み専用、書き込み専用、読み書き用に ファイルをオープンすることを要求するものである。
そのファイルディスクリプタを別のプロセスに UNIX ドメインソケット経由で渡す。 (\fBunix\fP(7) の \fBSCM_RIGHTS\fP を参照)
.RE
.IP
-\fIflags\fP に \fBO_PATH\fP が指定された場合、 \fBO_DIRECTORY\fP と \fBO_NOFOLLOW\fP
+\fIflags\fP に \fBO_PATH\fP が指定された場合、 \fBO_CLOEXEC\fP, \fBO_DIRECTORY\fP, \fBO_NOFOLLOW\fP
以外のフラグビットは無視される。
\fIpathname\fP がシンボリックリンクで \fBO_NOFOLLOW\fP フラグも合わせて指定された場合、
.\" Reported 2006-10-03
\fIpathname\fP が参照しているのが、大き過ぎてオープンできない通常のファイルである。 通常、このエラーが発生するは、32
ビットプラットフォーム上で \fI\-D_FILE_OFFSET_BITS=64\fP を指定せずにコンパイルされたアプリケーションが、ファイルサイズが
-\fI(2<31)\-1\fP ビットを超えるファイルを開こうとした場合である。 上記の \fBO_LARGEFILE\fP も参照。 これは
+\fI(1<31)\-1\fP バイトを超えるファイルを開こうとした場合である。 上記の \fBO_LARGEFILE\fP も参照。 これは
POSIX.1\-2001 で規定されているエラーである。 2.6.24 より前のカーネルでは、Linux はこの場合にエラー \fBEFBIG\fP
を返していた。
.TP
(それぞれ最終アクセス時刻、最終状態変更時刻、最終修正時刻である。 \fBstat\fP(2) 参照) が現在時刻に設定される。 さらに親ディレクトリの
\fIst_ctime\fP と \fIst_mtime\fP も現在時刻に設定される。 それ以外の場合で、O_TRUNC フラグでファイルが修正されたときは、
ファイルの \fIst_ctime\fP と \fIst_mtime\fP フィールドが現在時刻に設定される。
+.SS オープンファイル記述
+The term open file description is the one used by POSIX to refer to the
+entries in the system\-wide table of open files. In other contexts, this
+object is variously also called an "open file object", a "file handle", an
+"open file table entry", or\(emin kernel\-developer parlance\(ema \fIstruct
+file\fP.
+
+When a file descriptor is duplicated (using \fBdup\fP(2) or similar), the
+duplicate refers to the same open file description as the original file
+descriptor, and the two file descriptors consequently share the file offset
+and file status flags. Such sharing can also occur between processes: a
+child process created via \fBfork\fP(2) inherits duplicates of its parent's
+file descriptors, and those duplicates refer to the same open file
+descriptions.
+
+.\"
+.\"
+Each \fBopen\fP(2) of a file creates a new open file description; thus, there
+may be multiple open file descriptions corresponding to a file inode.
.SS "同期 I/O"
POSIX.1\-2008 の「同期 I/O」の選択肢として複数種類が規定されており、 動作を制御するために \fBopen\fP() フラグとして
\fBO_SYNC\fP, \fBO_DSYNC\fP, \fBO_RSYNC\fP が規定されている。 この選択肢を実装がサポートしているかに関わらず、
\fBread\fP(2), \fBsocket\fP(2), \fBstat\fP(2), \fBumask\fP(2), \fBunlink\fP(2),
\fBwrite\fP(2), \fBfopen\fP(3), \fBfifo\fP(7), \fBpath_resolution\fP(7), \fBsymlink\fP(7)
.SH この文書について
-この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.68 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.75 の一部
である。プロジェクトの説明とバグ報告に関する情報は
http://www.kernel.org/doc/man\-pages/ に書かれている。