-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
-.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
-.\" 1993 Michael Haardt, Ian Jackson.
-.\" 2008 Greg Banks
-.\"
-.\" 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 copy and distribute modified versions of this
-.\" manual under the conditions for verbatim copying, provided that the
-.\" entire resulting derived work is distributed under the terms of a
-.\" permission notice identical to this one.
-.\"
-.\" Since the Linux kernel and libraries are constantly changing, this
-.\" manual page may be incorrect or out-of-date. The author(s) assume no
-.\" responsibility for errors or omissions, or for damages resulting from
-.\" the use of the information contained herein. The author(s) may not
-.\" have taken the same level of care in the production of this manual,
-.\" which is licensed free of charge, as they might when working
-.\" professionally.
-.\"
-.\" Formatted or processed versions of this manual, if unaccompanied by
-.\" the source, must acknowledge the copyright and authors of this work.
-.\"
-.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
-.\" Modified 1994-08-21 by Michael Haardt
-.\" Modified 1996-04-13 by Andries Brouwer <aeb@cwi.nl>
-.\" Modified 1996-05-13 by Thomas Koenig
-.\" Modified 1996-12-20 by Michael Haardt
-.\" Modified 1999-02-19 by Andries Brouwer <aeb@cwi.nl>
-.\" Modified 1998-11-28 by Joseph S. Myers <jsm28@hermes.cam.ac.uk>
-.\" Modified 1999-06-03 by Michael Haardt
-.\" Modified 2002-05-07 by Michael Kerrisk <mtk.manpages@gmail.com>
-.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
-.\" 2004-12-08, mtk, reordered flags list alphabetically
-.\" 2004-12-08, Martin Pool <mbp@sourcefrog.net> (& mtk), added O_NOATIME
-.\" 2007-09-18, mtk, Added description of O_CLOEXEC + other minor edits
-.\" 2008-01-03, mtk, with input from Trond Myklebust
-.\" <trond.myklebust@fys.uio.no> and Timo Sirainen <tss@iki.fi>
-.\" Rewrite description of O_EXCL.
-.\" 2008-01-11, Greg Banks <gnb@melbourne.sgi.com>: add more detail
-.\" on O_DIRECT.
-.\" 2008-02-26, Michael Haardt: Reorganized text for O_CREAT and mode
-.\"
-.\" FIXME . Apr 08: The next POSIX revision has O_EXEC, O_SEARCH, and
-.\" O_TTYINIT. Eventually these may need to be documented. --mtk
-.\" FIXME Linux 2.6.33 has O_DSYNC, and a hidden __O_SYNC.
-.\"
-.\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
-.\" all rights reserved.
-.\" Translated 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
-.\" Updated 2001-05-25, Yuichi SATO <ysato444@yahoo.co.jp>
-.\" Updated & Modified 2002-01-02, Yuichi SATO
-.\" Updated & Modified 2002-07-07, Yuichi SATO
-.\" Updated & Modified 2002-09-19, Yuichi SATO
-.\" Updated & Modified 2003-07-30, Yuichi SATO
-.\" Updated & Modified 2003-11-27, Yuichi SATO
-.\" Updated & Modified 2005-01-01, Yuichi SATO
-.\" Updated & Modified 2005-09-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
-.\" Updated & Modified 2005-10-14, Akihiro MOTOKI
-.\" Updated & Modified 2006-01-18, Akihiro MOTOKI
-.\" Updated & Modified 2006-04-15, Akihiro MOTOKI, LDP v2.29
-.\" Updated 2007-01-07, Akihiro MOTOKI, LDP v2.43
-.\" Updated 2007-05-01, Akihiro MOTOKI, LDP v2.46
-.\" Updated 2007-10-12, Akihiro MOTOKI, LDP v2.66
-.\" Updated 2008-02-12, Akihiro MOTOKI, LDP v2.77
-.\" Updated 2008-04-04, Akihiro MOTOKI, LDP v2.79
-.\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
-.\" Updated 2010-04-23, Akihiro MOTOKI, LDP v3.24
-.\"
-.\"WORD: descriptor ディスクリプタ
-.\"WORD: file description ファイル記述
-.\"WORD: open オープン
-.\"WORD: create 作成
-.\"WORD: file offset ファイル・オフセット
-.\"WORD: controling terminal 制御端末
-.\"WORD: non-blocking I/O 非停止 I/O
-.\"WORD: synchronous I/O 同期 I/O
-.\"WORD: permission 許可
-.\"WORD: user ユーザー
-.\"WORD: owner 所有者
-.\"WORD: group グループ
-.\"WORD: other 他人
-.\"WORD: kernel カーネル
-.\"WORD: symbolic link シンボリック・リンク
-.\"WORD: dangling symbolic link 壊れたシンボリック・リンク
-.\"WORD: file creation flag ファイル作成フラグ
-.\"WORD: file status flag ファイル状態フラグ
-.\"
-.TH OPEN 2 2010-09-10 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH 名前
-.\"O open, creat \- open and possibly create a file or device
-open, creat \- ファイルやデバイスのオープン、作成を行う
-.\"O .SH SYNOPSIS
-.SH 書式
-.nf
-.B #include <sys/types.h>
-.B #include <sys/stat.h>
-.B #include <fcntl.h>
-.sp
-.BI "int open(const char *" pathname ", int " flags );
-.BI "int open(const char *" pathname ", int " flags ", mode_t " mode );
-
-.BI "int creat(const char *" pathname ", mode_t " mode );
-.fi
-.\"O .SH DESCRIPTION
-.SH 説明
-.\"O Given a
-.\"O .I pathname
-.\"O for a file,
-.\"O .BR open ()
-.\"O returns a file descriptor, a small, nonnegative integer
-.\"O for use in subsequent system calls
-.\"O .RB ( read "(2), " write "(2), " lseek "(2), " fcntl "(2), etc.)."
-.\"O The file descriptor returned by a successful call will be
-.\"O the lowest-numbered file descriptor not currently open for the process.
-ファイルの
-.I pathname
-を与えると、
-.BR open ()
-はファイル・ディスクリプタを返す。
-ファイル・ディスクリプタは、この後に続くシステムコール
-.RB ( read "(2), " write "(2), " lseek "(2), " fcntl "(2) など)"
-で使用される小さな非負の整数である。
-このシステムコールが成功した場合に返されるファイル・ディスクリプタは
-そのプロセスがその時点でオープンしていないファイル・ディスクリプタの
-うち最小の数字のものとなる。
-.PP
-.\"O By default, the new file descriptor is set to remain open across an
-.\"O .BR execve (2)
-.\"O (i.e., the
-.\"O .B FD_CLOEXEC
-.\"O file descriptor flag described in
-.\"O .BR fcntl (2)
-.\"O is initially disabled; the Linux-specific
-.\"O .B O_CLOEXEC
-.\"O flag, described below, can be used to change this default).
-.\"O The file offset is set to the beginning of the file (see
-.\"O .BR lseek (2)).
-デフォルトでは、新しいファイル・ディスクリプタは
-.BR execve (2)
-を実行した後もオープンされたままとなる (つまり、
-.BR fcntl (2)
-に説明がある
-.B FD_CLOEXEC
-ファイル・ディスクリプタ・フラグは最初は無効である;
-後述の Linux 固有のフラグ
-.B O_CLOEXEC
-を使うとこのデフォルトを変更することができる)。
-ファイル・オフセット (file offset) はファイルの先頭に設定される
-.RB ( lseek (2)
-参照)。
-.PP
-.\"O A call to
-.\"O .BR open ()
-.\"O creates a new
-.\"O .IR "open file description" ,
-.\"O an entry in the system-wide table of open files.
-.BR open ()
-を呼び出すと、「オープンファイル記述」
-.I "(open file description)"
-が作成される。ファイル記述とは、システム全体の
-オープン中のファイルのテーブルのエントリである。
-.\"O This entry records the file offset and the file status flags
-.\"O (modifiable via the
-.\"O .BR fcntl (2)
-.\"O .B F_SETFL
-.\"O operation).
-.\"O A file descriptor is a reference to one of these entries;
-.\"O this reference is unaffected if
-.\"O .I pathname
-.\"O is subsequently removed or modified to refer to a different file.
-このエントリは、ファイル・オフセットとファイル状態フラグ
-.RB ( fcntl (2)
-.B F_SETFL
-操作により変更可能) が保持する。
-ファイル・ディスクリプタはこれらのエントリの一つへの参照である。
-この後で
-.I pathname
-が削除されたり、他のファイルを参照するように変更されたりしても、
-この参照は影響を受けない。
-.\"O The new open file description is initially not shared
-.\"O with any other process,
-.\"O but sharing may arise via
-.\"O .BR fork (2).
-新しいオープンファイル記述は最初は他のどのプロセスとも
-共有されていないが、
-.BR fork (2)
-で共有が起こる場合がある。
-.PP
-.\"O The argument
-.\"O .I flags
-.\"O must include one of the following
-.\"O .IR "access modes" :
-.\"O .BR O_RDONLY ", " O_WRONLY ", or " O_RDWR .
-.\"O These request opening the file read-only, write-only, or read/write,
-.\"O respectively.
-引き数
-.I flags
-には、アクセスモード
-.BR O_RDONLY ", " O_WRONLY ", " O_RDWR
-のどれかひとつが入っていなければならない。
-これらはそれぞれ読み込み専用、書き込み専用、読み書き用に
-ファイルをオープンすることを要求するものである。
-
-.\"O In addition, zero or more file creation flags and file status flags
-.\"O can be
-.\"O .RI bitwise- or 'd
-.\"O in
-.\"O .IR flags .
-さらに、
-.I flags
-には、ファイル作成フラグ (file creation flag) とファイル状態フラグ
-(file status flag) を 0 個以上「ビット単位の OR (bitwise-or)」で
-指定することができる。
-.\"O The
-.\"O .I file creation flags
-.\"O are
-.\"O .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", and " O_TRUNC .
-.\"O The
-.\"O .I file status flags
-.\"O are all of the remaining flags listed below.
-.I ファイル作成フラグ
-は
-.BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC
-である。
-.I ファイル状態フラグ
-は以下のリストのうち上記以外の残りのものである。
-.\" FIXME . Actually is it true that the "file status flags" are all of the
-.\" remaining flags listed below? SUSv4 divides the flags into:
-.\" * Access mode
-.\" * File creation
-.\" * File status
-.\" * Other (O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW)
-.\" though it's not clear what the difference between "other" and
-.\" "File creation" flags is. (I've raised an Aardvark to see if this
-.\" can be clarified in SUSv4; 10 Oct 2008.)
-.\"O The distinction between these two groups of flags is that
-.\"O the file status flags can be retrieved and (in some cases)
-.\"O modified using
-.\"O .BR fcntl (2).
-.\"O The full list of file creation flags and file status flags is as follows:
-二種類のフラグの違いは、ファイル状態フラグの方は
-.BR fcntl (2)
-を使ってその内容を取得したり (場合によっては) 変更したりできる点にある。
-ファイル作成フラグとファイル状態フラグの全リストを以下に示す:
-.TP
-.B O_APPEND
-.\"O The file is opened in append mode.
-.\"O Before each
-.\"O .BR write (2),
-.\"O the file offset is positioned at the end of the file,
-.\"O as if with
-.\"O .BR lseek (2).
-ファイルを追加 (append) モードでオープンする。
-毎回の
-.BR write (2)
-の前に
-.BR lseek (2)
-を行ったかのように、ファイル・ポインターをファイルの最後に移動する。
-.\"O .B O_APPEND
-.\"O may lead to corrupted files on NFS file systems if more than one process
-.\"O appends data to a file at once.
-.\" For more background, see
-.\" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=453946
-.\" http://nfs.sourceforge.net/
-.\"O This is because NFS does not support
-.\"O appending to a file, so the client kernel has to simulate it, which
-.\"O can't be done without a race condition.
-NFS ファイル・システムで、
-.B O_APPEND
-を使用すると、複数のプロセスがひとつのファイルに同時にデータを追加した場合、
-ファイルが壊れてしまうことがある。
-これは NFS が追加モードをサポートしていないため、
-クライアントのカーネル (kernel) がそれをシミュレートしなければならないのだが、
-競合状態を避けることはできないからである。
-.TP
-.B O_ASYNC
-.\"O Enable signal-driven I/O:
-.\"O generate a signal
-.\"O .RB ( SIGIO
-.\"O by default, but this can be changed via
-.\"O .BR fcntl (2))
-.\"O when input or output becomes possible on this file descriptor.
-シグナル駆動 I/O (signal-driven I/O) を有効にする:
-このファイル・ディスクリプタへの
-入力または出力が可能になった場合に、シグナルを生成する
-(デフォルトは
-.B SIGIO
-であるが、
-.BR fcntl (2)
-によって変更可能である)。
-.\"O This feature is only available for terminals, pseudoterminals,
-.\"O sockets, and (since Linux 2.6) pipes and FIFOs.
-.\"O See
-.\"O .BR fcntl (2)
-.\"O for further details.
-この機能が使用可能なのは端末、疑似端末、ソケットのみであり、
-(Linux 2.6 以降では) パイプと FIFO に対しても使用できる。
-さらに詳しい説明は
-.BR fcntl (2)
-を参照すること。
-.TP
-.\"O .BR O_CLOEXEC " (Since Linux 2.6.23)"
-.BR O_CLOEXEC " (Linux 2.6.23 以降)"
-.\"O Enable the close-on-exec flag for the new file descriptor.
-新しいファイル・ディスクリプタに対して close-on-exec フラグを有効にする。
-.\"O Specifying this flag permits a program to avoid additional
-.\"O .BR fcntl (2)
-.\"O .B F_SETFD
-.\"O operations to set the
-.\"O .B FD_CLOEXEC
-.\"O flag.
-このフラグを指定することで、プログラムは
-.B FD_CLOEXEC
-フラグをセットするための
-.BR fcntl (2)
-.B F_SETFD
-操作を別途呼び出す必要がなくなる。
-.\"O Additionally,
-.\"O use of this flag is essential in some multithreaded programs
-.\"O since using a separate
-.\"O .BR fcntl (2)
-.\"O .B F_SETFD
-.\"O operation to set the
-.\"O .B FD_CLOEXEC
-.\"O flag does not suffice to avoid race conditions
-.\"O where one thread opens a file descriptor at the same
-.\"O time as another thread does a
-.\"O .BR fork (2)
-.\"O plus
-.\"O .BR execve (2).
-また、ある種のマルチスレッドのプログラムはこのフラグの使用は
-不可欠である。なぜなら、個別に
-.B FD_CLOEXEC
-フラグを設定する
-.BR fcntl (2)
-.B F_SETFD
-操作を呼び出したとしても、あるスレッドがファイルディスクリプタを
-オープンするのと同時に別のスレッドが
-.BR fork (2)
-と
-.BR execve (2)
-を実行するという競合条件を避けるのには十分ではないからである。
-.\" This flag fixes only one form of the race condition;
-.\" The race can also occur with, for example, descriptors
-.\" returned by accept(), pipe(), etc.
-.TP
-.B O_CREAT
-.\"O If the file does not exist it will be created.
-ファイルが存在しなかった場合は作成 (create) する。
-.\"O The owner (user ID) of the file is set to the effective user ID
-.\"O of the process.
-.\"O The group ownership (group ID) is set either to
-.\"O the effective group ID of the process or to the group ID of the
-.\"O parent directory (depending on file system type and mount options,
-.\"O and the mode of the parent directory, see the mount options
-.\"O .I bsdgroups
-.\"O and
-.\"O .I sysvgroups
-.\"O described in
-.\"O .BR mount (8)).
-.\"O .\" As at 2.6.25, bsdgroups is supported by ext2, ext3, ext4, and
-.\"O .\" XFS (since 2.6.14).
-ファイルの所有者 (ユーザー ID) は、プロセスの実効ユーザー ID に設定される。
-グループ所有権 (グループ ID) は、プロセスの実効グループ ID
-または親ディレクトリのグループ ID に設定される
-(これは、ファイルシステムタイプ、マウントオプション、
-親ディレクトリのモードに依存する。
-.BR mount (8)
-で説明されているマウントオプション
-.I bsdgroups
-と
-.I sysvgroups
-を参照)。
-.\" 2.6.25 時点では、bsdgroups は ext2, ext3, ext4, XFS でサポート
-.\" されている (2.6.14 以降)。
-.RS
-.PP
-.\"O .I mode
-.\"O specifies the permissions to use in case a new file is created.
-.\"O This argument must be supplied when
-.\"O .B O_CREAT
-.\"O is specified in
-.\"O .IR flags ;
-.\"O if
-.\"O .B O_CREAT
-.\"O is not specified, then
-.\"O .I mode
-.\"O is ignored.
-.\"O The effective permissions are modified by
-.\"O the process's
-.\"O .I umask
-.\"O in the usual way: The permissions of the created file are
-.\"O .IR "(mode\ &\ ~umask)" .
-.I mode
-は新しいファイルを作成する場合に使用するアクセス許可 (permission) を指定する。
-.I flags
-に
-.B O_CREAT
-が指定されている場合、
-.I mode
-を指定しなければならない。
-.B O_CREAT
-が指定されていない場合、
-.I mode
-は無視される。
-有効なアクセス許可は、普段と同じようにプロセスの
-.I umask
-によって修正され、作成されたファイルの許可は
-.I "(mode\ &\ ~umask)"
-となる。
-.\"O Note that this mode only applies to future accesses of the
-.\"O newly created file; the
-.\"O .BR open ()
-.\"O call that creates a read-only file may well return a read/write
-.\"O file descriptor.
-このモードは、新しく作成されたファイルに対するそれ以降のアクセス
-にのみ適用される点に注意すること。
-読み取り専用のファイルを作成する
-.BR open ()
-コールであっても、
-読み書き可能なファイル・ディスクリプタを返すことがありうる。
-.PP
-.\"O The following symbolic constants are provided for
-.\"O .IR mode :
-.I mode
-のために以下のシンボル定数が提供されている :
-.TP 9
-.B S_IRWXU
-.\"O 00700 user (file owner) has read, write and execute permission
-00700 ユーザー (ファイルの所有者) に読み込み、書き込み、
-実行の許可がある。
-.TP
-.B S_IRUSR
-.\"O 00400 user has read permission
-00400 ユーザーに読み込みの許可がある。
-.TP
-.B S_IWUSR
-.\"O 00200 user has write permission
-00200 ユーザーに書き込みの許可がある。
-.TP
-.B S_IXUSR
-.\"O 00100 user has execute permission
-00100 ユーザーに実行の許可がある。
-.TP
-.B S_IRWXG
-.\"O 00070 group has read, write and execute permission
-00070 グループに読み込み、書き込み、実行の許可がある。
-.TP
-.B S_IRGRP
-.\"O 00040 group has read permission
-00040 グループに読み込みの許可がある。
-.TP
-.B S_IWGRP
-.\"O 00020 group has write permission
-00020 グループに書き込みの許可がある。
-.TP
-.B S_IXGRP
-.\"O 00010 group has execute permission
-00010 グループに実行の許可がある。
-.TP
-.B S_IRWXO
-.\"O 00007 others have read, write and execute permission
-00007 他人 (others) に読み込み、書き込み、実行の許可がある。
-.TP
-.B S_IROTH
-.\"O 00004 others have read permission
-00004 他人に読み込みの許可がある。
-.TP
-.B S_IWOTH
-.\"O 00002 others have write permission
-00002 他人に書き込みの許可がある。
-.TP
-.B S_IXOTH
-.\"O 00001 others have execute permission
-00001 他人に実行の許可がある。
-.RE
-.TP
-.\"O .BR O_DIRECT " (Since Linux 2.4.10)"
-.BR O_DIRECT " (Linux 2.4.10 以降)"
-.\"O Try to minimize cache effects of the I/O to and from this file.
-.\"O In general this will degrade performance, but it is useful in
-.\"O special situations, such as when applications do their own caching.
-.\"O File I/O is done directly to/from user space buffers.
-このファイルに対する I/O のキャッシュの効果を最小化しようとする。
-このフラグを使うと、一般的に性能が低下する。
-しかしアプリケーションが独自にキャッシングを行っているような
-特別な場合には役に立つ。
-ファイルの I/O はユーザー空間バッファに対して直接行われる。
-.\"O The
-.\"O .B O_DIRECT
-.\"O flag on its own makes at an effort to transfer data synchronously,
-.\"O but does not give the guarantees of the
-.\"O .B O_SYNC
-.\"O that data and necessary metadata are transferred.
-.B O_DIRECT
-フラグ自身はデータを同期で転送しようとはするが、
-.B O_SYNC
-のようにデータと必要なメタデータの転送が保証されるわけではない。
-.\"O To guarantee synchronous I/O the
-.\"O .B O_SYNC
-.\"O must be used in addition to
-.\"O .BR O_DIRECT .
-同期 I/O を保証するためには、
-.B O_DIRECT
-に加えて
-.B O_SYNC
-を使用しなければならない。
-.\"O See
-.\"O .B NOTES
-.\"O below for further discussion.
-「注意」の節 (下記) の議論も参照。
-.sp
-.\"O A semantically similar (but deprecated) interface for block devices
-.\"O is described in
-.\"O .BR raw (8).
-ブロックデバイスに対する似通った意味のインターフェースが
-.BR raw (8)
-で説明されている (但し、このインタフェースは非推奨である)。
-.TP
-.B O_DIRECTORY
-.\"O If \fIpathname\fP is not a directory, cause the open to fail.
-.\"O .\" But see the following and its replies:
-.\"O .\" http://marc.theaimsgroup.com/?t=112748702800001&r=1&w=2
-.\"O .\" [PATCH] open: O_DIRECTORY and O_CREAT together should fail
-.\"O .\" O_DIRECTORY | O_CREAT causes O_DIRECTORY to be ignored.
-.\"O This flag is Linux-specific, and was added in kernel version 2.1.126, to
-.\"O avoid denial-of-service problems if
-.\"O .BR opendir (3)
-.\"O is called on a
-.\"O FIFO or tape device, but should not be used outside of the
-.\"O implementation of
-.\"O .BR opendir (3).
-\fIpathname\fP がディレクトリでなければオープンは失敗する。
-.\" 以下の記事とそのリプライを参照のこと。
-.\" http://marc.theaimsgroup.com/?t=112748702800001&r=1&w=2
-.\" [PATCH] open: O_DIRECTORY and O_CREAT together should fail
-.\" O_DIRECTORY | O_CREAT を指定すると O_DIRECTORY が無視されてしまう。
-このフラグは Linux 特有であり、
-.BR opendir (3)
-が FIFO やテープデバイスに対してコールされた場合の
-サービス不能 (denial-of-service) 攻撃を避けるために
-カーネル 2.1.126 で追加された。
-しかしこれは
-.BR opendir (3)
-の実装以外では使用するべきではない。
-.TP
-.B O_EXCL
-.\"O Ensure that this call creates the file:
-.\"O if this flag is specified in conjunction with
-.\"O .BR O_CREAT ,
-.\"O and
-.\"O .I pathname
-.\"O already exists, then
-.\"O .BR open ()
-.\"O will fail.
-.\"O The behavior of
-.\"O .B O_EXCL
-.\"O is undefined if
-.\"O .B O_CREAT
-.\"O is not specified.
-この呼び出しでファイルが作成されることを保証する。
-このフラグが
-.B O_CREAT
-と一緒に指定され、
-.I pathname
-のファイルが既に存在した場合、
-.BR open ()
-は失敗する。
-.B O_CREAT
-が指定されなかった場合の
-.B O_EXCL
-の動作は未定義である。
-
-.\"O When these two flags are specified, symbolic links are not followed:
-.\"O .\" POSIX.1-2001 explicitly requires this behavior.
-.\"O if
-.\"O .I pathname
-.\"O is a symbolic link, then
-.\"O .BR open ()
-.\"O fails regardless of where the symbolic link points to.
-これら二つのフラグが指定された際、シンボリックリンクは辿られない。
-.\" POSIX.1-2001 では明示的にこの動作を要求している。
-.I pathname
-がシンボリックリンクの場合、
-シンボリックリンクがどこを指しているかに関わらず
-.BR open ()
-は失敗する。
-
-.\"O On NFS,
-.\"O .B O_EXCL
-.\"O is only supported when using NFSv3 or later on kernel 2.6 or later.
-NFS では、
-.B O_EXCL
-は、Linux 2.6 以降で NFSv3 以降を使っている場合でのみサポートされる。
-.\"O In NFS environments where
-.\"O .B O_EXCL
-.\"O support is not provided, programs that rely on it
-.\"O for performing locking tasks will contain a race condition.
-.\"O Portable programs that want to perform atomic file locking using a lockfile,
-.\"O and need to avoid reliance on NFS support for
-.\"O .BR O_EXCL ,
-.\"O can create a unique file on
-.\"O the same file system (e.g., incorporating hostname and PID), and use
-.\"O .BR link (2)
-.\"O to make a link to the lockfile.
-.B O_EXCL
-サポートが提供されていない NFS 環境では、このフラグに頼って
-ロック処理を実行するプログラムは競合状態 (race condition) に出会う
-可能性がある。
-ロックファイルを使用して不可分 (atomic) なファイルロックを実現し、
-NFS が
-.B O_EXCL
-をサポートしているかに依存しないようにしたい場合、
-移植性のある方法は、同じファイルシステム上に他と名前の重ならない
-ファイル (例えばホスト名と PID を組み合わせた名前) を作成し、
-.BR link (2)
-を使用してそのロックファイルへのリンクを作成することである。
-.\"O If
-.\"O .BR link (2)
-.\"O returns 0, the lock is successful.
-.\"O Otherwise, use
-.\"O .BR stat (2)
-.\"O on the unique file to check if its link count has increased to 2,
-.\"O in which case the lock is also successful.
-.BR link (2)
-コールの返り値が 0 ならばロックに成功している。
-あるいは、そのファイルに
-.BR stat (2)
-を使用してリンク数 (link count) が 2 になっているかをチェックする。
-そうなっていれば、同じくロックに成功しているということである。
-.TP
-.B O_LARGEFILE
-(LFS)
-.\"O Allow files whose sizes cannot be represented in an
-.\"O .I off_t
-.\"O (but can be represented in an
-.\"O .IR off64_t )
-.\"O to be opened.
-.\"O The
-.\"O .B _LARGEFILE64_SOURCE
-.\"O macro must be defined
-.\"O (before including
-.\"O .I any
-.\"O header files)
-.\"O in order to obtain this definition.
-.\"O Setting the
-.\"O .B _FILE_OFFSET_BITS
-.\"O feature test macro to 64 (rather than using
-.\"O .BR O_LARGEFILE )
-.\"O is the preferred method of obtaining
-.\"O method of accessing large files on 32-bit systems (see
-.\"O .BR feature_test_macros (7)).
-.I off_t
-ではサイズを表せない (だだし
-.I off64_t
-ではサイズを表せる) ファイルをオープン可能にする。
-この定義を有効にするためには、
-(「どの」ヘッダファイルをインクルードするよりも前に)
-.B _LARGEFILE64_SOURCE
-マクロを定義しなければならない。
-32ビットシステムにおいて大きなファイルにアクセスする方法を得たい場合、
-.RB ( O_LARGEFILE
-を使うよりも)
-.B _FILE_OFFSET_BITS
-機能検査マクロをセットする方が望ましい方法である
-.RB ( feature_test_macros (7)
-を参照)。
-.TP
-.\"O .BR O_NOATIME " (Since Linux 2.6.8)"
-.BR O_NOATIME " (Linux 2.6.8 以降)"
-.\"O Do not update the file last access time (st_atime in the inode)
-.\"O when the file is
-.\"O .BR read (2).
-ファイルに対して
-.BR read (2)
-が実行されたときに、最終アクセス時刻 (inode の st_atime) を更新しない。
-.\"O This flag is intended for use by indexing or backup programs,
-.\"O where its use can significantly reduce the amount of disk activity.
-このフラグはインデックス作成やバックアッププログラムで使うことを意図している。
-これを使うとディスクに対する操作を大幅に減らすことができる。
-.\"O This flag may not be effective on all file systems.
-.\"O One example is NFS, where the server maintains the access time.
-このフラグは全てのファイルシステムに対して有効であるわけではない。
-その一例が NFS であり、サーバがアクセス時刻を管理している。
-.\" The O_NOATIME flag also affects the treatment of st_atime
-.\" by mmap() and readdir(2), MTK, Dec 04.
-.TP
-.B O_NOCTTY
-.\"O If
-.\"O .I pathname
-.\"O refers to a terminal device \(em see
-.\"O .BR tty (4)
-.\"O \(em it will not become the process's controlling terminal even if the
-.\"O process does not have one.
-.I pathname
-が端末 (terminal) デバイス
-\(em
-.BR tty (4)
-参照
-\(em
-を指している場合に、たとえそのプロセスが制御端末を持っていなくても、
-オープンしたファイルは制御端末にはならない。
-.TP
-.B O_NOFOLLOW
-.\"O If \fIpathname\fP is a symbolic link, then the open fails.
-.\"O This is a FreeBSD extension, which was added to Linux in version 2.1.126.
-.\"O Symbolic links in earlier components of the pathname will still be
-.\"O followed.
-.\"O .\" The headers from glibc 2.0.100 and later include a
-.\"O .\" definition of this flag; \fIkernels before 2.1.126 will ignore it if
-.\"O .\" used\fP.
-\fIpathname\fP がシンボリック・リンクだった場合、オープンは失敗する。
-これは FreeBSD の拡張で、Linux には 2.1.126 より追加された。
-pathname の前のコンポーネント (earlier component;
-訳註: 最後のディレクトリセパレータより前の部分) が
-シンボリック・リンクである場合には、それが指す先が参照される。
-.\" glibc 2.0.100 以降のヘッダーにはこのフラグの定義がある。
-.\" \fI2.1.126 以前のカーネルで使用した場合には無視される。\fP
-.TP
-.\"O .BR O_NONBLOCK " or " O_NDELAY
-.BR O_NONBLOCK " または " O_NDELAY
-.\"O When possible, the file is opened in nonblocking mode.
-.\"O Neither the
-.\"O .BR open ()
-.\"O nor any subsequent operations on the file descriptor which is
-.\"O returned will cause the calling process to wait.
-.\"O For the handling of FIFOs (named pipes), see also
-.\"O .BR fifo (7).
-.\"O For a discussion of the effect of
-.\"O .B O_NONBLOCK
-.\"O in conjunction with mandatory file locks and with file leases, see
-.\"O .BR fcntl (2).
-可能ならば、ファイルは非停止 (nonblocking) モードでオープンされる。
-.BR open ()
-も、返したファイル・ディスクリプタに対する以後のすべての操作も
-呼び出したプロセスを待たせることはない。
-FIFO (ネームド・パイプ) を扱う場合には
-.BR fifo (7)
-も参照すること。
-強制ファイルロック (mandatory file lock) やファイルリース (file lease)
-と組み合わせた場合の、
-.B O_NONBLOCK
-の効果についての議論は、
-.BR fcntl (2)
-を参照すること。
-.TP
-.B O_SYNC
-.\"O The file is opened for synchronous I/O.
-.\"O Any
-.\"O .BR write (2)s
-.\"O on the resulting file descriptor will block the calling process until
-.\"O the data has been physically written to the underlying hardware.
-.\"O .IR "But see NOTES below" .
-ファイルは同期 (synchronous) I/O モードでオープンされる。
-.BR open ()
-が返したファイル・ディスクリプタに対して
-.BR write (2)
-を行うと、必ず呼び出したプロセスをブロックし、
-該当ハードウェアに物理的に書き込まれるまで返らない。
-.I 以下の「注意」の章も参照。
-.TP
-.B O_TRUNC
-.\"O If the file already exists and is a regular file and the open mode allows
-.\"O writing (i.e., is
-.\"O .B O_RDWR
-.\"O or
-.\"O .BR O_WRONLY )
-.\"O it will be truncated to length 0.
-.\"O If the file is a FIFO or terminal device file, the
-.\"O .B O_TRUNC
-.\"O flag is ignored.
-.\"O Otherwise the effect of
-.\"O .B O_TRUNC
-.\"O is unspecified.
-ファイルが既に存在し、通常ファイルであり、
-書き込み可モードでオープンされている
-(つまり、
-.BR O_RDWR "または" O_WRONLY
-の) 場合、長さ 0 に切り詰め (truncate) られる。
-ファイルが FIFO または端末デバイスファイルの場合、
-.B O_TRUNC
-フラグは無視される。
-それ以外の場合、
-.B O_TRUNC
-の効果は未定義である。
-.PP
-.\"O Some of these optional flags can be altered using
-.\"O .BR fcntl (2)
-.\"O after the file has been opened.
-これらの選択フラグのいくつかはファイルをオープンした後でも
-.BR fcntl (2)
-を使用して変更することができる。
-
-.\"O .BR creat ()
-.\"O is equivalent to
-.\"O .BR open ()
-.\"O with
-.\"O .I flags
-.\"O equal to
-.\"O .BR O_CREAT|O_WRONLY|O_TRUNC .
-.BR creat ()
-は
-.I flags
-に
-.B O_CREAT|O_WRONLY|O_TRUNC
-を指定して
-.BR open ()
-を行うのと等価である。
-.\"O .SH "RETURN VALUE"
-.SH 返り値
-.\"O .BR open ()
-.\"O and
-.\"O .BR creat ()
-.\"O return the new file descriptor, or \-1 if an error occurred
-.\"O (in which case,
-.\"O .I errno
-.\"O is set appropriately).
-.BR open ()
-と
-.BR creat ()
-は新しいファイル・ディスクリプタを返す。
-エラーが発生した場合は \-1 を返す
-(その場合は
-.I errno
-が適切に設定される)。
-.\"O .SH ERRORS
-.SH エラー
-.TP
-.B EACCES
-.\"O The requested access to the file is not allowed, or search permission
-.\"O is denied for one of the directories in the path prefix of
-.\"O .IR pathname ,
-.\"O or the file did not exist yet and write access to the parent directory
-.\"O is not allowed.
-.\"O (See also
-.\"O .BR path_resolution (7).)
-ファイルに対する要求されたアクセスが許されていないか、
-.I pathname
-のディレクトリ部分の何れかのディレクトリに検索許可がなかった。
-またはファイルが存在せず、親ディレクトリへの書き込み許可がなかった。
-.RB ( path_resolution (7)
-も参照すること。)
-.TP
-.B EEXIST
-.\"O .I pathname
-.\"O already exists and
-.\"O .BR O_CREAT " and " O_EXCL
-.\"O were used.
-.I pathname
-は既に存在し、
-.BR O_CREAT " と " O_EXCL
-が使用された。
-.TP
-.B EFAULT
-.\"O .I pathname
-.\"O points outside your accessible address space.
-.I pathname
-の指す領域がアクセス可能なアドレス空間にない。
-.TP
-.B EFBIG
-.\"O See
-.\"O .BR EOVERFLOW .
-.B EOVERFLOW
-参照。
-.TP
-.B EINTR
-.\"O While blocked waiting to complete an open of a slow device
-.\"O (e.g., a FIFO; see
-.\"O .BR fifo (7)),
-.\"O the call was interrupted by a signal handler; see
-.\"O .BR signal (7).
-遅いデバイス
-(例えば FIFO、
-.BR fifo (7)
-参照) のオープンが完了するのを待って停止している間に
-システムコールがシグナルハンドラにより割り込まれた。
-.BR signal (7)
-参照。
-.TP
-.B EISDIR
-.\"O .I pathname
-.\"O refers to a directory and the access requested involved writing
-.\"O (that is,
-.\"O .B O_WRONLY
-.\"O or
-.\"O .B O_RDWR
-.\"O is set).
-.I pathname
-はディレクトリを参照しており、書き込み要求が含まれていた
-(つまり
-.B O_WRONLY
-または
-.B O_RDWR
-が設定されている)。
-.TP
-.B ELOOP
-.\"O Too many symbolic links were encountered in resolving
-.\"O .IR pathname ,
-.\"O or \fBO_NOFOLLOW\fP was specified but
-.\"O .I pathname
-.\"O was a symbolic link.
-.I pathname
-を解決する際に遭遇したシンボリック・リンクが多過ぎる。
-または \fBO_NOFOLLOW\fP が指定されており、
-.I pathname
-がシンボリックリンクだった。
-.TP
-.B EMFILE
-.\"O The process already has the maximum number of files open.
-プロセスがオープンしているファイル数がすでに最大数に達している。
-.TP
-.B ENAMETOOLONG
-.\"O .I pathname
-.\"O was too long.
-.I pathname
-が長過ぎる。
-.TP
-.B ENFILE
-.\"O The system limit on the total number of open files has been reached.
-オープンできるファイルの合計数がシステム制限に達している。
-.TP
-.B ENODEV
-.\"O .I pathname
-.\"O refers to a device special file and no corresponding device exists.
-.\"O (This is a Linux kernel bug; in this situation
-.\"O .B ENXIO
-.\"O must be returned.)
-.I pathname
-がデバイス・スペシャル・ファイルを参照しており、対応するデバイスが存在しない。
-(これは Linux カーネルのバグであり、この場合には
-.B ENXIO
-が返されるべきである)
-.TP
-.B ENOENT
-.\"O .B O_CREAT
-.\"O is not set and the named file does not exist.
-.\"O Or, a directory component in
-.\"O .I pathname
-.\"O does not exist or is a dangling symbolic link.
-.B O_CREAT
-が設定されておらず、かつ指定されたファイルが存在しない。
-または、
-.I pathname
-のディレクトリ部分が存在しないか壊れた (dangling) シンボリック・リンクである。
-.TP
-.B ENOMEM
-.\"O Insufficient kernel memory was available.
-カーネルに利用できるメモリが不足している
-.TP
-.B ENOSPC
-.\"O .I pathname
-.\"O was to be created but the device containing
-.\"O .I pathname
-.\"O has no room for the new file.
-.I pathname
-を作成する必要があるが、
-.I pathname
-を含んでいるデバイスに新しいファイルのための空き容量がない。
-.TP
-.B ENOTDIR
-.\"O A component used as a directory in
-.\"O .I pathname
-.\"O is not, in fact, a directory, or \fBO_DIRECTORY\fP was specified and
-.\"O .I pathname
-.\"O was not a directory.
-.I pathname
-に含まれるディレクトリ部分のどれかが実際にはディレクトリでない。
-または \fBO_DIRECTORY\fP が指定されており、
-.I pathname
-がディレクトリでない。
-.TP
-.B ENXIO
-.\"O .BR O_NONBLOCK " | " O_WRONLY
-.\"O is set, the named file is a FIFO and
-.\"O no process has the file open for reading.
-.\"O Or, the file is a device special file and no corresponding device exists.
-.BR O_NONBLOCK " | " O_WRONLY
-が設定されており、指定したファイルが FIFO で
-そのファイルを読み込みのためにオープンしているプロセスが存在しない。
-または、ファイルがデバイス・スペシャル・ファイルで
-対応するデバイスが存在しない。
-.TP
-.B EOVERFLOW
-.\"O .I pathname
-.\"O refers to a regular file that is too large to be opened.
-.\"O The usual scenario here is that an application compiled
-.\"O on a 32-bit platform without
-.\"O .I -D_FILE_OFFSET_BITS=64
-.\"O tried to open a file whose size exceeds
-.\"O .I (2<<31)-1
-.\"O bits;
-.\"O see also
-.\"O .B O_LARGEFILE
-.\"O above.
-.\"O This is the error specified by POSIX.1-2001;
-.\"O in kernels before 2.6.24, Linux gave the error
-.\"O .B EFBIG
-.\"O for this case.
-.I pathname
-が参照しているのが、大き過ぎてオープンできない通常のファイルである。
-通常、このエラーが発生するは、32 ビットプラットフォーム上で
-.I -D_FILE_OFFSET_BITS=64
-を指定せずにコンパイルされたアプリケーションが、ファイルサイズが
-.I (2<31)-1
-ビットを超えるファイルを開こうとした場合である。
-上記の
-.B O_LARGEFILE
-も参照。
-これは POSIX.1-2001 で規定されているエラーである。
-2.6.24 より前のカーネルでは、Linux はこの場合にエラー
-.B EFBIG
-を返していた。
-.\" See http://bugzilla.kernel.org/show_bug.cgi?id=7253
-.\" "Open of a large file on 32-bit fails with EFBIG, should be EOVERFLOW"
-.\" Reported 2006-10-03
-.TP
-.B EPERM
-.\"O The
-.\"O .B O_NOATIME
-.\"O flag was specified, but the effective user ID of the caller
-.\"O .\" Strictly speaking, it's the file system UID... (MTK)
-.\"O did not match the owner of the file and the caller was not privileged
-.\"O .RB ( CAP_FOWNER ).
-.B O_NOATIME
-フラグが指定されたが、呼び出し元の実効ユーザー ID が
-.\" 厳密に言えば、呼び出し元のファイルシステム UID...(MTK)
-ファイルの所有者と一致せず、かつ呼び出し元に特権
-.RB ( CAP_FOWNER )
-がない。
-.TP
-.B EROFS
-.\"O .I pathname
-.\"O refers to a file on a read-only file system and write access was
-.\"O requested.
-.I pathname
-が読み込み専用のファイルシステム上のファイルを参照しており、
-書き込みアクセスが要求された。
-.TP
-.B ETXTBSY
-.\"O .I pathname
-.\"O refers to an executable image which is currently being executed and
-.\"O write access was requested.
-.I pathname
-が現在実行中の実行イメージを参照しており、書き込みが要求された。
-.TP
-.B EWOULDBLOCK
-.\"O The
-.\"O .B O_NONBLOCK
-.\"O flag was specified, and an incompatible lease was held on the file
-.\"O (see
-.\"O .BR fcntl (2)).
-.B O_NONBLOCK
-フラグが指定されたが、そのファイルには矛盾するリースが設定されていた
-.RB ( fcntl (2)
-参照)。
-.\"O .SH "CONFORMING TO"
-.SH 準拠
-SVr4, 4.3BSD, POSIX.1-2001.
-.\"O The
-.\"O .BR O_DIRECTORY ,
-.\"O .BR O_NOATIME ,
-.\"O and
-.\"O .B O_NOFOLLOW
-.\"O flags are Linux-specific, and one may need to define
-.\"O .B _GNU_SOURCE
-.\"O (before including
-.\"O .I any
-.\"O header files)
-.\"O to obtain their definitions.
-フラグ
-.BR O_DIRECTORY ,
-.BR O_NOATIME ,
-.B O_NOFOLLOW
-は Linux 特有のものであり、
-これらのフラグの定義を得るためには、
-(「どの」ヘッダファイルをインクルードするよりも前に)
-.B _GNU_SOURCE
-を定義する必要があるかもしれない。
-
-.\"O The
-.\"O .BR O_CLOEXEC
-.\"O flag is not specified in POSIX.1-2001,
-.\"O but is specified in POSIX.1-2008.
-.BR O_CLOEXEC
-フラグは POSIX.1-2001 では規定されていないが、
-POSIX.1-2008 で規定されている。
-
-.\"O .B O_DIRECT
-.\"O is not specified in POSIX; one has to define
-.\"O .B _GNU_SOURCE
-.\"O (before including
-.\"O .I any
-.\"O header files)
-.\"O to get its definition.
-.B O_DIRECT
-は POSIX では規定されていない。
-.B O_DIRECT
-の定義を得るには
-(「どの」ヘッダファイルをインクルードするよりも前に)
-.B _GNU_SOURCE
-を定義しなければならない。
-.\"O .SH NOTES
-.SH 注意
-.\"O Under Linux, the
-.\"O .B O_NONBLOCK
-.\"O flag indicates that one wants to open
-.\"O but does not necessarily have the intention to read or write.
-Linux では、
-.B O_NONBLOCK
-フラグは、
-open を実行したいが read または write を実行する意図は
-必ずしもないことを意味する。
-.\"O This is typically used to open devices in order to get a file descriptor
-.\"O for use with
-.\"O .BR ioctl (2).
-これは
-.BR ioctl (2)
-のためのファイルディスクリプタを取得するために、
-デバイスをオープンするときによく用いられる。
-
-.\"O Unlike the other values that can be specified in
-.\"O .IR flags ,
-.\"O the
-.\"O .I "access mode"
-.\"O values
-.\"O .BR O_RDONLY ", " O_WRONLY ", and " O_RDWR ,
-.\"O do not specify individual bits.
-.\"O Rather, they define the low order two bits of
-.\"O .IR flags ,
-.\"O and are defined respectively as 0, 1, and 2.
-「アクセスモード」の値
-.BR O_RDONLY ", " O_WRONLY ", " O_RDWR
-は、
-.I flags
-に指定できる他の値と違い、個々のビットを指定するものではなく、
-これらの値は
-.I flags
-の下位 2 ビットを定義する。
-.BR O_RDONLY ", " O_WRONLY ", " O_RDWR
-はそれぞれ 0, 1, 2 に定義されている。
-.\"O In other words, the combination
-.\"O .B "O_RDONLY | O_WRONLY"
-.\"O is a logical error, and certainly does not have the same meaning as
-.\"O .BR O_RDWR .
-言い換えると、
-.B "O_RDONLY | O_WRONLY"
-の組み合わせは論理的に間違いであり、確かに
-.B O_RDWR
-と同じ意味ではない。
-.\"O Linux reserves the special, nonstandard access mode 3 (binary 11) in
-.\"O .I flags
-.\"O to mean:
-.\"O check for read and write permission on the file and return a descriptor
-.\"O that can't be used for reading or writing.
-.\"O This nonstandard access mode is used by some Linux drivers to return a
-.\"O descriptor that is only to be used for device-specific
-.\"O .BR ioctl (2)
-.\"O operations.
-Linux では、特別な、非標準なアクセスモードとして 3 (バイナリでは 11) が
-予約されており
-.I flags
-に指定できる。
-このアクセスモードを指定すると、ファイルの読み出し/書き込み許可をチェックし、
-読み出しにも書き込みにも使用できないディスクリプタを返す。
-この非標準のアクセスモードはいくつかの Linux ドライバで使用されており、
-デバイス固有の
-.BR ioctl (2)
-操作にのみ使用されるディスクリプタを返すために使われている。
-.\" See for example util-linux's disk-utils/setfdprm.c
-.\" For some background on access mode 3, see
-.\" http://thread.gmane.org/gmane.linux.kernel/653123
-.\" "[RFC] correct flags to f_mode conversion in __dentry_open"
-.\" LKML, 12 Mar 2008
-.LP
-.\"O The (undefined) effect of
-.\"O .B O_RDONLY | O_TRUNC
-.\"O varies among implementations.
-.\"O On many systems the file is actually truncated.
-.B O_RDONLY | O_TRUNC
-の影響は未定義であり、その動作は実装によって異なる。
-多くのシステムではファイルは実際に切り詰められる。
-.\" Linux 2.0, 2.5: truncate
-.\" Solaris 5.7, 5.8: truncate
-.\" Irix 6.5: truncate
-.\" Tru64 5.1B: truncate
-.\" HP-UX 11.22: truncate
-.\" FreeBSD 4.7: truncate
-.PP
-.\"O There are many infelicities in the protocol underlying NFS, affecting
-.\"O amongst others
-.\"O .BR O_SYNC " and " O_NDELAY .
-NFS を実現しているプロトコルには多くの不備があり、特に
-.BR O_SYNC " と " O_NDELAY
-に影響する。
-
-.\"O POSIX provides for three different variants of synchronized I/O,
-.\"O corresponding to the flags
-.\"O .BR O_SYNC ,
-.\"O .BR O_DSYNC ,
-.\"O and
-.\"O .BR O_RSYNC .
-POSIX では、3 種類の同期 I/O が提供されており、
-.BR O_SYNC ,
-.BR O_DSYNC ,
-.BR O_RSYNC
-フラグがこれに対応するものである。
-.\"O Currently (2.6.31), Linux only implements
-.\"O .BR O_SYNC ,
-.\"O but glibc maps
-.\"O .B O_DSYNC
-.\"O and
-.\"O .B O_RSYNC
-.\"O to the same numerical value as
-.\"O .BR O_SYNC .
-今のところ (カーネル 2.6.31)、
-Linux では
-.B O_SYNC
-だけが実装されているが、
-glibc は
-.B O_DSYNC
-と
-.B O_RSYNC
-に
-.B O_SYNC
-と同じ数値を割り当てている。
-.\"O Most Linux file systems don't actually implement the POSIX
-.\"O .B O_SYNC
-.\"O semantics, which require all metadata updates of a write
-.\"O to be on disk on returning to userspace, but only the
-.\"O .B O_DSYNC
-.\"O semantics, which require only actual file data and metadata necessary
-.\"O to retrieve it to be on disk by the time the system call returns.
-ほとんどの Linux のファイルシステムは、実際には POSIX の
-.B O_SYNC
-の動作ではなく
-.B O_DSYNC
-の動作だけを実装している。
-POSIX の
-.B O_SYNC
-では、
-.BR open ()
-がユーザ空間に返る際に、書き込みに関する全てのメタデータの
-更新がディスクに書き込まれている必要がある。
-一方、
-.B O_DSYNC
-では、
-.BR open ()
-が返るまでに、実際のファイルのデータとそのデータを取得するために
-必要なメタデータだけがディスクに書き込まれていればよい。
-
-.\"O Note that
-.\"O .BR open ()
-.\"O can open device special files, but
-.\"O .BR creat ()
-.\"O cannot create them; use
-.\"O .BR mknod (2)
-.\"O instead.
-.BR open ()
-はスペシャル・ファイルをオープンすることができるが、
-.BR creat ()
-でスペシャル・ファイルを作成できない点に注意すること。
-代わりに
-.BR mknod (2)
-を使用する。
-.LP
-.\"O On NFS file systems with UID mapping enabled,
-.\"O .BR open ()
-.\"O may
-.\"O return a file descriptor but, for example,
-.\"O .BR read (2)
-.\"O requests are denied
-.\"O with \fBEACCES\fP.
-.\"O This is because the client performs
-.\"O .BR open ()
-.\"O by checking the
-.\"O permissions, but UID mapping is performed by the server upon
-.\"O read and write requests.
-UID マッピングを使用している NFS ファイル・システムでは、
-.BR open ()
-がファイル・ディスクリプタを返した場合でも
-.BR read (2)
-が \fBEACCES\fP で拒否される場合がある。
-これはクライアントがアクセス許可のチェックを行って
-.BR open ()
-を実行するが、読み込みや書き込みの際には
-サーバーで UID マッピングが行われるためである。
-
-.\"O If the file is newly created, its
-.\"O .IR st_atime ,
-.\"O .IR st_ctime ,
-.\"O .I st_mtime
-.\"O fields
-.\"O (respectively, time of last access, time of last status change, and
-.\"O time of last modification; see
-.\"O .BR stat (2))
-.\"O are set
-.\"O to the current time, and so are the
-.\"O .I st_ctime
-.\"O and
-.\"O .I st_mtime
-.\"O fields of the
-.\"O parent directory.
-.\"O Otherwise, if the file is modified because of the
-.\"O .B O_TRUNC
-.\"O flag, its st_ctime and st_mtime fields are set to the current time.
-ファイルが新しく作成されると、
-ファイルの
-.IR st_atime ,
-.IR st_ctime ,
-.I st_mtime
-フィールド
-(それぞれ最終アクセス時刻、最終状態変更時刻、最終修正時刻である。
-.BR stat (2)
-参照) が現在時刻に設定される。
-さらに親ディレクトリの
-.I st_ctime
-と
-.I st_mtime
-も現在時刻に設定される。
-それ以外の場合で、O_TRUNC フラグでファイルが修正されたときは、
-ファイルの
-.I st_ctime
-と
-.I st_mtime
-フィールドが現在時刻に設定される。
-.SS O_DIRECT
-.LP
-.\"O The
-.\"O .B O_DIRECT
-.\"O flag may impose alignment restrictions on the length and address
-.\"O of userspace buffers and the file offset of I/Os.
-.\"O In Linux alignment
-.\"O restrictions vary by file system and kernel version and might be
-.\"O absent entirely.
-.\"O However there is currently no file system\-independent
-.\"O interface for an application to discover these restrictions for a given
-.\"O file or file system.
-.\"O Some file systems provide their own interfaces
-.\"O for doing so, for example the
-.\"O .B XFS_IOC_DIOINFO
-.\"O operation in
-.\"O .BR xfsctl (3).
-.B O_DIRECT
-フラグを使用する場合、ユーザ空間バッファの長さやアドレス、
-I/O のファイルオフセットに関してアラインメントの制限が課されることがある。
-Linux では、アラインメントの制限はファイルシステムやカーネルのバージョンに
-よって異なり、全く制限が存在しない場合もある。
-しかしながら、現在のところ、指定されたファイルやファイルシステムに対して
-こうした制限があるかを見つけるための、アプリケーション向けのインタフェースで
-ファイルシステム非依存のものは存在しない。
-いくつかのファイルシステムでは、制限を確認するための独自のインタフェースが
-提供されている。例えば、
-.BR xfsctl (3)
-の
-.B XFS_IOC_DIOINFO
-命令である。
-.LP
-.\"O Under Linux 2.4, transfer sizes, and the alignment of the user buffer
-.\"O and the file offset must all be multiples of the logical block size
-.\"O of the file system.
-.\"O Under Linux 2.6, alignment to 512-byte boundaries
-.\"O suffices.
-Linux 2.4 では、転送サイズ、
-ユーザーバッファのアラインメント、ファイルオフセットは、
-ファイルシステムの論理ブロックサイズの倍数でなければならない。
-Linux 2.6 では、512 バイトごとの境界に配置されていれば充分である。
-.LP
-.\"O The
-.\"O .B O_DIRECT
-.\"O flag was introduced in SGI IRIX, where it has alignment
-.\"O restrictions similar to those of Linux 2.4.
-.\"O IRIX has also a
-.\"O .BR fcntl (2)
-.\"O call to query appropriate alignments, and sizes.
-.\"O FreeBSD 4.x introduced
-.\"O a flag of the same name, but without alignment restrictions.
-.B O_DIRECT
-フラグは SGI IRIX で導入された。SGI IRIX にも Linux 2.4 と同様の
-(ユーザーバッファの) アラインメントの制限がある。
-また、IRIX には適切な配置とサイズを取得するための
-.BR fcntl (2)
-コールがある。
-FreeBSD 4.x も同じ名前のフラグを導入したが、アラインメントの制限はない。
-.LP
-.\"O .B O_DIRECT
-.\"O support was added under Linux in kernel version 2.4.10.
-.\"O Older Linux kernels simply ignore this flag.
-.\"O Some file systems may not implement the flag and
-.\"O .BR open ()
-.\"O will fail with
-.\"O .B EINVAL
-.\"O if it is used.
-.B O_DIRECT
-が Linux でサポートされたのは、カーネルバージョン 2.4.10 である。
-古い Linux カーネルは、このフラグを単に無視する。
-.B O_DIRECT
-フラグをサポートしていないファイルシステムもあり、その場合は、
-.B O_DIRECT
-を使用すると
-.BR open ()
-は
-.B EINVAL
-で失敗する。
-.LP
-.\"O Applications should avoid mixing
-.\"O .B O_DIRECT
-.\"O and normal I/O to the same file,
-.\"O and especially to overlapping byte regions in the same file.
-.\"O Even when the file system correctly handles the coherency issues in
-.\"O this situation, overall I/O throughput is likely to be slower than
-.\"O using either mode alone.
-.\"O Likewise, applications should avoid mixing
-.\"O .BR mmap (2)
-.\"O of files with direct I/O to the same files.
-アプリケーションは、同じファイル、
-特に同じファイルの重複するバイト領域に対して、
-.B O_DIRECT
-と通常の I/O を混ぜて使うのは避けるべきである。
-ファイルシステムがこのような状況において一貫性の問題を正しく
-扱うことができる場合であっても、全体の I/O スループットは
-どちらか一方を使用するときと比べて低速になるであろう。
-同様に、アプリケーションは、同じファイルに対して
-.BR mmap (2)
-と直接 I/O
-.RB ( O_DIRECT )
-を混ぜて使うのも避けるべきである。
-.LP
-.\"O The behaviour of
-.\"O .B O_DIRECT
-.\"O with NFS will differ from local file systems.
-.\"O Older kernels, or
-.\"O kernels configured in certain ways, may not support this combination.
-.\"O The NFS protocol does not support passing the flag to the server, so
-.\"O .B O_DIRECT
-.\"O I/O will only bypass the page cache on the client; the server may
-.\"O still cache the I/O.
-NFS で
-.B O_DIRECT
-を使った場合の動作はローカルのファイルシステムの場合と違う。
-古いカーネルや、ある種の設定でコンパイルされたカーネルは、
-.B O_DIRECT
-と NFS の組み合わせをサポートしていないかもしれない。
-NFS プロトコル自体はサーバにフラグを渡す機能は持っていないので、
-.B O_DIRECT
-I/O はクライアント上のページキャッシュをバイパスするだけになり、
-サーバは I/O をキャッシュしているかもしれない。
-.\"O The client asks the server to make the I/O
-.\"O synchronous to preserve the synchronous semantics of
-.\"O .BR O_DIRECT .
-.\"O Some servers will perform poorly under these circumstances, especially
-.\"O if the I/O size is small.
-.\"O Some servers may also be configured to
-.\"O lie to clients about the I/O having reached stable storage; this
-.\"O will avoid the performance penalty at some risk to data integrity
-.\"O in the event of server power failure.
-.\"O The Linux NFS client places no alignment restrictions on
-.\"O .B O_DIRECT
-.\"O I/O.
-クライアントは、
-.B O_DIRECT
-の同期機構を保持するため、サーバに対して I/O を同期して行うように依頼する。
-サーバによっては、こうした状況下、特に I/O サイズが小さい場合に
-性能が大きく劣化する。
-また、サーバによっては、I/O が安定したストレージにまで行われたと、
-クライアントに対して嘘をつくものもある。
-これは、サーバの電源故障が起こった際にデータの完全性が保たれない
-危険は少しあるが、性能面での不利な条件を回避するために行われている。
-Linux の NFS クライアントでは
-.B O_DIRECT
-I/O
-でのアラインメントの制限はない。
-.PP
-.\"O In summary,
-.\"O .B O_DIRECT
-.\"O is a potentially powerful tool that should be used with caution.
-.\"O It is recommended that applications treat use of
-.\"O .B O_DIRECT
-.\"O as a performance option which is disabled by default.
-まとめると、
-.B O_DIRECT
-は、注意して使うべきであるが、強力なツールとなる可能性を持っている。
-アプリケーションは
-.B O_DIRECT
-をデフォルトでは無効になっている性能向上のためのオプションと
-考えておくのがよいであろう。
-.PP
-.RS
-.\"O "The thing that has always disturbed me about O_DIRECT is that the whole
-.\"O interface is just stupid, and was probably designed by a deranged monkey
-.\"O on some serious mind-controlling substances." \(em Linus
-「O_DIRECT でいつも困るのは、インタフェース全部が本当にお馬鹿な点だ。
-たぶん危ないマインドコントロール剤で
-頭がおかしくなったサルが設計したんじゃないかな」 \(em Linus
-.RE
-.\"O .SH BUGS
-.SH バグ
-.\"O Currently, it is not possible to enable signal-driven
-.\"O I/O by specifying
-.\"O .B O_ASYNC
-.\"O when calling
-.\"O .BR open ();
-.\"O use
-.\"O .BR fcntl (2)
-.\"O to enable this flag.
-現在のところ、
-.BR open ()
-の呼び出し時に
-.B O_ASYNC
-を指定してシグナル駆動 I/O を有効にすることはできない。
-このフラグを有効にするには
-.BR fcntl (2)
-を使用すること。
-.\" FIXME . Check bugzilla report on open(O_ASYNC)
-.\" See http://bugzilla.kernel.org/show_bug.cgi?id=5993
-.\"O .SH "SEE ALSO"
-.SH 関連項目
-.BR chmod (2),
-.BR chown (2),
-.BR close (2),
-.BR dup (2),
-.BR fcntl (2),
-.BR link (2),
-.BR lseek (2),
-.BR mknod (2),
-.BR mmap (2),
-.BR mount (2),
-.BR openat (2),
-.BR read (2),
-.BR socket (2),
-.BR stat (2),
-.BR umask (2),
-.BR unlink (2),
-.BR write (2),
-.BR fopen (3),
-.BR fifo (7),
-.BR path_resolution (7),
-.BR symlink (7)