-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
-.\" 1993 Michael Haardt, Ian Jackson.
-.\" 2008 Greg Banks
+.\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
+.\" and Copyright (C) 2008 Greg Banks
+.\" and Copyright (C) 2006, 2008, 2013, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
+.\" %%%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
.\"
.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
.\" Modified 1994-08-21 by Michael Haardt
.\"
.\" 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 hiddden __O_SYNC.
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
.\"
.\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
.\" all rights reserved.
.\" 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
+.\" Updated 2012-05-08, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2012-05-30, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-08-16, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.\"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 2009-09-20 "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 ½ñ¼°
+.TH OPEN 2 2014\-04\-20 Linux "Linux Programmer's Manual"
+.SH 名前
+open, openat, creat \- ファイルのオープン、作成を行う
+.SH 書式
.nf
-.B #include <sys/types.h>
-.B #include <sys/stat.h>
-.B #include <fcntl.h>
+\fB#include <sys/types.h>\fP
+\fB#include <sys/stat.h>\fP
+\fB#include <fcntl.h>\fP
.sp
-.BI "int open(const char *" pathname ", int " flags );
-.BI "int open(const char *" pathname ", int " flags ", mode_t " mode );
+\fBint open(const char *\fP\fIpathname\fP\fB, int \fP\fIflags\fP\fB);\fP
+\fBint open(const char *\fP\fIpathname\fP\fB, int \fP\fIflags\fP\fB, mode_t \fP\fImode\fP\fB);\fP
-.BI "int creat(const char *" pathname ", mode_t " mode );
+\fBint creat(const char *\fP\fIpathname\fP\fB, mode_t \fP\fImode\fP\fB);\fP
+.sp
+\fBint openat(int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB, int \fP\fIflags\fP\fB);\fP
+\fBint openat(int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB, int \fP\fIflags\fP\fB, mode_t \fP\fImode\fP\fB);\fP
.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) ¤Ê¤É)"
-¤Ç»ÈÍѤµ¤ì¤ë¾®¤µ¤ÊÈóÉé¤ÎÀ°¿ô¤Ç¤¢¤ë¡£
-¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬À®¸ù¤·¤¿¾ì¹ç¤ËÊÖ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
-¤½¤Î¥×¥í¥»¥¹¤¬¤½¤Î»þÅÀ¤Ç¥ª¡¼¥×¥ó¤·¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
-¤¦¤ÁºÇ¾®¤Î¿ô»ú¤Î¤â¤Î¤È¤Ê¤ë¡£
+.sp
+.in -4n
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
+.in
+.sp
+\fBopenat\fP():
+.PD 0
+.ad l
+.RS 4
+.TP 4
+glibc 2.10 以降:
+_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
+.TP
+glibc 2.10 より前:
+_ATFILE_SOURCE
+.RE
+.ad
+.PD
+.SH 説明
+ファイルの \fIpathname\fP を与えると、 \fBopen\fP() はファイルディスクリプタを返す。
+ファイルディスクリプタは、この後に続くシステムコール (\fBread\fP(2), \fBwrite\fP(2), \fBlseek\fP(2),
+\fBfcntl\fP(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)
-»²¾È)¡£
+デフォルトでは、新しいファイルディスクリプタは \fBexecve\fP(2) を実行した後も
+オープンされたままとなる (つまり、 \fBfcntl\fP(2) に説明がある \fBFD_CLOEXEC\fP
+ファイルディスクリプタフラグは最初は無効である; 後述の \fBO_CLOEXEC\fP フラグ
+を使うとこのデフォルトを変更することができる)。 ファイルオフセット
+(file offset) はファイルの先頭に設定される (\fBlseek\fP(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)
-¤Ç¶¦Í¤¬µ¯¤³¤ë¾ì¹ç¤¬¤¢¤ë¡£
+\fBopen\fP() を呼び出すと、「オープンファイル記述」 \fI(open file description)\fP
+が作成される。ファイル記述とは、システム全体の オープン中のファイルのテーブルのエントリである。 このエントリは、ファイルオフセットとファイル状態フラグ
+(\fBfcntl\fP(2) \fBF_SETFL\fP 操作により変更可能) が保持する。 ファイルディスクリプタはこれらのエントリの一つへの参照である。
+この後で \fIpathname\fP が削除されたり、他のファイルを参照するように変更されたりしても、 この参照は影響を受けない。
+新しいオープンファイル記述は最初は他のどのプロセスとも 共有されていないが、 \fBfork\fP(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
-¤Î¤É¤ì¤«¤Ò¤È¤Ä¤¬Æþ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
-¤³¤ì¤é¤Ï¤½¤ì¤¾¤ìÆɤ߹þ¤ßÀìÍÑ¡¢½ñ¤¹þ¤ßÀìÍÑ¡¢Æɤ߽ñ¤ÍѤË
-¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë¤³¤È¤òÍ׵᤹¤ë¤â¤Î¤Ç¤¢¤ë¡£
+引き数 \fIflags\fP には、アクセスモード \fBO_RDONLY\fP, \fBO_WRONLY\fP, \fBO_RDWR\fP
+のどれかひとつが入っていなければならない。 これらはそれぞれ読み込み専用、書き込み専用、読み書き用に ファイルをオープンすることを要求するものである。
-.\"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:
+.\" 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.
+.\" "File creation" flags is. I raised an Aardvark to see if this
+.\" can be clarified in SUSv4; 10 Oct 2008.
+.\" http://thread.gmane.org/gmane.comp.standards.posix.austin.general/64/focus=67
+.\" TC1 (balloted in 2013), resolved this, so that those three constants
+.\" are also categorized" as file status flags.
+.\"
+さらに、 \fIflags\fP には、ファイル作成フラグ (file creation flag) とファイル状態フラグ (file status
+flag) を 0 個以上「ビット単位の OR (bitwise\-or)」で 指定することができる。 \fIファイル作成フラグ\fP は
+\fBO_CLOEXEC\fP, \fBO_CREAT\fP, \fBO_DIRECTORY\fP, \fBO_EXCL\fP, \fBO_NOCTTY\fP,
+\fBO_NOFOLLOW\fP, \fBO_TMPFILE\fP, \fBO_TRUNC\fP, \fBO_TTY_INIT\fP である。 \fIファイル状態フラグ\fP
+は以下のリストのうち上記以外の残りのものである。 二種類のフラグの違いは、ファイル状態フラグの方はその内容を取得したり (場合によっては)
+変更したりできる点にある。詳細は \fBfcntl\fP(2) を参照。
+
+The full list of file creation flags and file status flags is as follows:
+.TP
+\fBO_APPEND\fP
.\" 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, pseudo-terminals,
-.\"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)
-¤ò¼Â¹Ô¤¹¤ë¤È¤¤¤¦¶¥¹ç¾ò·ï¤òÈò¤±¤ë¤Î¤Ë¤Ï½½Ê¬¤Ç¤Ï¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
+ファイルを追加 (append) モードでオープンする。 毎回の \fBwrite\fP(2) の前に \fBlseek\fP(2)
+を行ったかのように、ファイルポインタをファイルの最後に移動する。 NFS ファイルシステムで、 \fBO_APPEND\fP
+を使用すると、複数のプロセスがひとつのファイルに同時にデータを追加した場合、 ファイルが壊れてしまうことがある。 これは NFS
+が追加モードをサポートしていないため、 クライアントのカーネル (kernel) がそれをシミュレートしなければならないのだが、
+競合状態を避けることはできないからである。
+.TP
+\fBO_ASYNC\fP
+シグナル駆動 I/O (signal\-driven I/O) を有効にする: このファイルディスクリプタへの
+入力または出力が可能になった場合に、シグナルを生成する (デフォルトは \fBSIGIO\fP であるが、 \fBfcntl\fP(2)
+によって変更可能である)。 この機能が使用可能なのは端末、疑似端末、ソケットのみであり、 (Linux 2.6 以降では) パイプと FIFO
+に対しても使用できる。 さらに詳しい説明は \fBfcntl\fP(2) を参照すること。 下記の「バグ」も参照。
+.TP
+\fBO_CLOEXEC\fP (Linux 2.6.23 以降)
+.\" NOTE! several otehr man pages refer to this text
+Enable the close\-on\-exec flag for the new file descriptor. Specifying this
+flag permits a program to avoid additional \fBfcntl\fP(2) \fBF_SETFD\fP
+operations to set the \fBFD_CLOEXEC\fP flag.
+
.\" 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 °Ê¹ß)¡£
+Note that the use of this flag is essential in some multithreaded programs,
+because using a separate \fBfcntl\fP(2) \fBF_SETFD\fP operation to set the
+\fBFD_CLOEXEC\fP flag does not suffice to avoid race conditions where one
+thread opens a file descriptor and attempts to set its close\-on\-exec flag
+using \fBfcntl\fP(2) at the same time as another thread does a \fBfork\fP(2)
+plus \fBexecve\fP(2). Depending on the order of execution, the race may lead
+to the file desriptor returned by \fBopen\fP() being unintentionally leaked to
+the program executed by the child process created by \fBfork\fP(2). (This kind
+of race is in principle possible for any system call that creates a file
+descriptor whose close\-on\-exec flag should be set, and various other Linux
+system calls provide an equivalent of the \fBO_CLOEXEC\fP flag to deal with
+this problem.)
+.TP
+\fBO_CREAT\fP
+.\" As at 2.6.25, bsdgroups is supported by ext2, ext3, ext4, and
+.\" XFS (since 2.6.14).
+ファイルが存在しなかった場合は作成 (create) する。 ファイルの所有者 (ユーザー ID) は、プロセスの実効ユーザー ID に設定される。
+グループ所有権 (グループ ID) は、プロセスの実効グループ ID または親ディレクトリのグループ ID に設定される
+(これは、ファイルシステムタイプ、マウントオプション、 親ディレクトリのモードに依存する。 \fBmount\fP(8) で説明されているマウントオプション
+\fIbsdgroups\fP と \fIsysvgroups\fP を参照)。
.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 ()
-¥³¡¼¥ë¤Ç¤¢¤Ã¤Æ¤â¡¢
-Æɤ߽ñ¤²Äǽ¤Ê¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¤³¤È¤¬¤¢¤ê¤¦¤ë¡£
+\fImode\fP は新しいファイルを作成する場合に使用するアクセス許可 (permission) を指定する。 \fIflags\fP に \fBO_CREAT\fP
+か \fBO_TMPFILE\fP が指定されている場合、 \fImode\fP を指定しなければならない。 \fBO_CREAT\fP も \fBO_TMPFILE\fP
+も指定されていない場合、 \fImode\fP は無視される。 有効なアクセス許可は、普段と同じようにプロセスの \fIumask\fP
+によって修正され、作成されたファイルの許可は \fI(mode\ &\ ~umask)\fP となる。
+このモードは、新しく作成されたファイルに対するそれ以降のアクセス にのみ適用される点に注意すること。 読み取り専用のファイルを作成する
+\fBopen\fP() コールであっても、 読み書き可能なファイルディスクリプタを返すことがありうる。
.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 ¾¿Í¤Ë¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
+\fImode\fP のために以下のシンボル定数が提供されている :
+.TP 9
+\fBS_IRWXU\fP
+00700 ユーザー (ファイルの所有者) に読み込み、書き込み、 実行の許可がある。
+.TP
+\fBS_IRUSR\fP
+00400 ユーザーに読み込みの許可がある。
+.TP
+\fBS_IWUSR\fP
+00200 ユーザーに書き込みの許可がある。
+.TP
+\fBS_IXUSR\fP
+00100 ユーザーに実行の許可がある。
+.TP
+\fBS_IRWXG\fP
+00070 グループに読み込み、書き込み、実行の許可がある。
+.TP
+\fBS_IRGRP\fP
+00040 グループに読み込みの許可がある。
+.TP
+\fBS_IWGRP\fP
+00020 グループに書き込みの許可がある。
+.TP
+\fBS_IXGRP\fP
+00010 グループに実行の許可がある。
+.TP
+\fBS_IRWXO\fP
+00007 他人 (others) に読み込み、書き込み、実行の許可がある。
+.TP
+\fBS_IROTH\fP
+00004 他人に読み込みの許可がある。
+.TP
+\fBS_IWOTH\fP
+00002 他人に書き込みの許可がある。
+.TP
+\fBS_IXOTH\fP
+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.
-¡ÖÃí°Õ¡×¤ÎÀá (²¼µ) ¤ÎµÄÏÀ¤â»²¾È¡£
+.TP
+\fBO_DIRECT\fP (Linux 2.4.10 以降)
+このファイルに対する I/O のキャッシュの効果を最小化しようとする。このフラグを使うと、一般的に性能が低下する。
+しかしアプリケーションが独自にキャッシングを行っているような 特別な場合には役に立つ。 ファイルの I/O はユーザー空間バッファに対して直接行われる。
+\fBO_DIRECT\fP フラグ自身はデータを同期で転送しようとはするが、 \fBO_SYNC\fP
+フラグのようにデータと必要なメタデータの転送が保証されるわけではない。同期 I/O を保証するためには、 \fBO_DIRECT\fP に加えて
+\fBO_SYNC\fP を使用しなければならない。下記の「注意」の節の議論も参照。
.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 ¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤±¤ì¤Ð¥ª¡¼¥×¥ó¤Ï¼ºÇÔ¤¹¤ë¡£
-.\" °Ê²¼¤Îµ»ö¤È¤½¤Î¥ê¥×¥é¥¤¤ò»²¾È¤Î¤³¤È¡£
+ブロックデバイスに対する似通った意味のインターフェースが \fBraw\fP(8) で説明されている (但し、このインタフェースは非推奨である)。
+.TP
+\fBO_DIRECTORY\fP
+.\" But see the following and its replies:
.\" 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_DIRECTORY | O_CREAT causes O_DIRECTORY to be ignored.
+\fIpathname\fP がディレクトリでなければオープンは失敗する。 このフラグは、 \fBopendir\fP(3) が FIFO
+やテープデバイスに対してコールされた場合の サービス不能 (denial\-of\-service) 攻撃を避けるために カーネル 2.1.126
+で追加された。
+.TP
+\fBO_DSYNC\fP
+Write operations on the file will complete according to the requirements of
+synchronized I/O \fIdata\fP integrity completion.
+
+By the time \fBwrite\fP(2) (and similar) return, the output data has been
+transferred to the underlying hardware, along with any file metadata that
+would be required to retrieve that data (i.e., as though each \fBwrite\fP(2)
+was followed by a call to \fBfdatasync\fP(2)). \fISee NOTES below\fP.
+.TP
+\fBO_EXCL\fP
+この呼び出しでファイルが作成されることを保証する。このフラグが \fBO_CREAT\fP と
+一緒に指定され、 \fIpathname\fP のファイルが既に存在した場合、 \fBopen\fP() は失敗
+する。
+
+.\" POSIX.1-2001 explicitly requires this behavior.
+これら二つのフラグが指定された際、シンボリックリンクは辿られない。 \fIpathname\fP がシンボリックリンクの場合、
+シンボリックリンクがどこを指しているかに関わらず \fBopen\fP() は失敗する。
-.\"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 ()
-¤Ï¼ºÇÔ¤¹¤ë¡£
+一般的には、 \fBO_CREAT\fP を指定せずに \fBO_EXCL\fP を使用した場合の
+\fBO_EXCL\fP の動作は規定されていない。
+これには一つ例外があり、Linux 2.6 以降では、
+\fIpathname\fP がブロックデバイスを参照している場合、
+\fBO_CREAT\fP なしで \fBO_EXCL\fP を使用することができる。
+システムがそのブロックデバイスを使用中の場合 (例えば、
+マウントされているなど)、 \fBopen\fP() はエラー \fBEBUSY\fP で失敗する。
-.\"O .B O_EXCL
-.\"O is only supported on NFS when using NFSv3 or later on kernel 2.6 or later.
-.B O_EXCL
-¤Ï¡¢Linux 2.6 °Ê¹ß¤Ç NFSv3 °Ê¹ß¤ò»È¤Ã¤Æ¤¤¤ë NFS ¤Ç¤Î¤ß¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
-.\"O In environments where NFS
-.\"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.
-NFS ¤Î
-.B O_EXCL
-¥µ¥Ý¡¼¥È¤¬Ä󶡤µ¤ì¤Æ¤¤¤Ê¤¤´Ä¶¤Ç¤Ï¡¢¤³¤Î¥Õ¥é¥°¤ËÍê¤Ã¤Æ
-¥í¥Ã¥¯½èÍý¤ò¼Â¹Ô¤¹¤ë¥×¥í¥°¥é¥à¤Ï¶¥¹ç¾õÂÖ (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 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 ¤Ç¤¢¤ê¡¢¥µ¡¼¥Ð¤¬¥¢¥¯¥»¥¹»þ¹ï¤ò´ÉÍý¤·¤Æ¤¤¤ë¡£
+NFS では、 \fBO_EXCL\fP は、Linux 2.6 以降で NFSv3 以降を使っている場合でのみサポートされる。 \fBO_EXCL\fP
+サポートが提供されていない NFS 環境では、このフラグに頼って ロック処理を実行するプログラムは競合状態 (race condition) に出会う
+可能性がある。 ロックファイルを使用して不可分 (atomic) なファイルロックを実現し、 NFS が \fBO_EXCL\fP
+をサポートしているかに依存しないようにしたい場合、 移植性のある方法は、同じファイルシステム上に他と名前の重ならない ファイル (例えばホスト名と
+PID を組み合わせた名前) を作成し、 \fBlink\fP(2) を使用してそのロックファイルへのリンクを作成することである。 \fBlink\fP(2)
+コールの返り値が 0 ならばロックに成功している。 あるいは、そのファイルに \fBstat\fP(2) を使用してリンク数 (link count) が
+2 になっているかをチェックする。 そうなっていれば、同じくロックに成功しているということである。
+.TP
+\fBO_LARGEFILE\fP
+(LFS) \fIoff_t\fP ではサイズを表せない (だだし \fIoff64_t\fP ではサイズを表せる)ファ
+イルをオープン可能にする。この定義を有効にするためには、(\fIどの\fPヘッダファイ
+ルをインクルードするよりも前に) \fB_LARGEFILE64_SOURCE\fP マクロを定義しなければ
+ならない。
+32 ビットシステムにおいて大きなファイルにアクセスしたい場合、
+(\fBO_LARGEFILE\fP を使うよりも) \fB_FILE_OFFSET_BITS\fP 機能検査マクロを 64 に
+セットする方が望ましい方法である (\fBfeature_test_macros\fP(7) を参照)。
+.TP
+\fBO_NOATIME\fP (Linux 2.6.8 以降)
.\" 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)
-¤ò»ÈÍѤ·¤ÆÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
+ファイルに対して \fBread\fP(2) が実行されたときに、最終アクセス時刻 (inode の \fIst_atime\fP) を更新しない。
+このフラグはインデックス作成やバックアッププログラムで使うことを意図している。 これを使うとディスクに対する操作を大幅に減らすことができる。
+このフラグは全てのファイルシステムに対して有効であるわけではない。 その一例が NFS であり、サーバがアクセス時刻を管理している。
+.TP
+\fBO_NOCTTY\fP
+\fIpathname\fP が端末 (terminal) デバイス \(em \fBtty\fP(4) 参照 \(em を指している
+場合に、たとえそのプロセスが制御端末を持っていなくても、オープンしたファイル
+は制御端末にはならない。
+.TP
+\fBO_NOFOLLOW\fP
+.\" The headers from glibc 2.0.100 and later include a
+.\" definition of this flag; \fIkernels before 2.1.126 will ignore it if
+.\" used\fP.
+\fIpathname\fP がシンボリックリンクだった場合、オープンは失敗する。 これは FreeBSD の拡張で、Linux には バージョン
+2.1.126 で追加された。 このフラグが指定された場合でも \fIpathname\fP の前の方の要素 (最後のディレクトリセパレータより前の部分)
+にあるシンボリックリンクについてはリンクが辿られる。 下記の \fBO_PATH\fP も参照のこと。
+.TP
+\fBO_NONBLOCK\fP または \fBO_NDELAY\fP
+可能ならば、ファイルは非停止 (nonblocking) モードでオープンされる。
+\fBopen\fP() も、返したファイルディスクリプタに対する以後のすべての操作も呼び出
+したプロセスを待たせることはない。 FIFO (名前付きパイプ) を扱う場合には
+\fBfifo\fP(7) も参照すること。 強制ファイルロック (mandatory file lock) やファイ
+ルリース (file lease) と組み合わせた場合の、 \fBO_NONBLOCK\fP の効果についての
+議論は、 \fBfcntl\fP(2) を参照すること。
+.TP
+\fBO_PATH\fP (Linux 2.6.39 以降)
+.\" commit 1abf0c718f15a56a0a435588d1b104c7a37dc9bd
+.\" commit 326be7b484843988afe57566b627fb7a70beac56
+.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d
+.\"
+.\" http://thread.gmane.org/gmane.linux.man/2790/focus=3496
+.\" Subject: Re: [PATCH] open(2): document O_PATH
+.\" Newsgroups: gmane.linux.man, gmane.linux.kernel
+.\"
+このフラグを指定して取得したファイルディスクリプタは、 ファイルシステムツリー内での場所を示すため、
+純粋にファイルディスクリプタレベルでの作用する操作を実行するため、 の二つの目的で使用することができる。 ファイル自身はオープンされず、
+他のファイル操作 (例えば \fBread\fP(2), \fBwrite\fP(2), \fBfchmod\fP(2), \fBfchown\fP(2),
+\fBfgetxattr\fP(2), \fBmmap\fP(2)) はエラー \fBEBADF\fP で失敗する。
+
+取得したファイルディスクリプタに対して以下の操作を行うことが「できる」。
+.RS
+.IP * 3
+.\" commit 332a2e1244bd08b9e3ecd378028513396a004a24
+.\" fstat(): commit 55815f70147dcfa3ead5738fd56d3574e2e3c1c2
+\fBclose\fP(2); \fBfchdir\fP(2) (Linux 3.5 以降); \fBfstat\fP(2) (Linux 3.6 以降)
+.IP *
+ファイルディスクリプタの複製 (\fBdup\fP(2), \fBfcntl\fP(2) \fBF_DUPFD\fP など)
+.IP *
+ファイルディスクリプタフラグの取得と設定 (\fBfcntl\fP(2) の \fBF_GETFD\fP と \fBF_SETFD\fP)
+.IP *
+\fBfcntl\fP(2) の \fBF_GETFL\fP 操作を使ったオープンされたファイルの状態フラグの取得。 返されるフラグには \fBO_PATH\fP
+ビットが含まれる。
+
+.IP *
+\fBopenat\fP(2) や他の "*at()" 系のシステムコールの \fIdirfd\fP 引数としてそのファイルディスクリプタを渡す。
+.IP *
+そのファイルディスクリプタを別のプロセスに UNIX ドメインソケット経由で渡す。 (\fBunix\fP(7) の \fBSCM_RIGHTS\fP を参照)
+.RE
+.IP
+\fIflags\fP に \fBO_PATH\fP が指定された場合、 \fBO_DIRECTORY\fP と \fBO_NOFOLLOW\fP
+以外のフラグビットは無視される。
+
+\fIpathname\fP がシンボリックリンクで \fBO_NOFOLLOW\fP フラグも合わせて指定された場合、
+この呼び出しではシンボリックリンクを参照するファイルディスクリプタを返す。 このファイルディスクリプタは、 空のパス名を指定した
+\fBfchownat\fP(2), \fBfstatat\fP(2), \fBlinkat\fP(2), \fBreadlinkat\fP(2) の呼び出しで
+\fIdirfd\fP 引数として使うことで、 そのシンボリックリンクに対して操作を行うことができる。
+.TP
+\fBO_SYNC\fP
+Write operations on the file will complete according to the requirements of
+synchronized I/O \fIfile\fP integrity completion (by contrast with contrast
+with the synchronized I/O \fIdata\fP integrity completion provided by
+\fBO_DSYNC\fP.)
+
+By the time \fBwrite\fP(2) (and similar) return, the output data and
+associated file metadata have been transferred to the underlying hardware
+(i.e., as though each \fBwrite\fP(2) was followed by a call to \fBfsync\fP(2)).
+\fISee NOTES below\fP.
+.TP
+\fBO_TMPFILE\fP (Linux 3.11 以降)
+.\" commit 60545d0d4610b02e55f65d141c95b18ccf855b6e
+.\" commit f4e0c30c191f87851c4a53454abb55ee276f4a7e
+.\" commit bb458c644a59dbba3a1fe59b27106c5e68e1c4bd
+Create an unnamed temporary file. The \fIpathname\fP argument specifies a
+directory; an unnamed inode will be created in that directory's filesystem.
+Anything written to the resulting file will be lost when the last file
+descriptor is closed, unless the file is given a name.
+
+\fBO_TMPFILE\fP must be specified with one of \fBO_RDWR\fP or \fBO_WRONLY\fP and,
+optionally, \fBO_EXCL\fP. If \fBO_EXCL\fP is not specified, then \fBlinkat\fP(2)
+can be used to link the temporary file into the filesystem, making it
+permanent, using code like the following:
+
+.in +4n
+.nf
+char path[PATH_MAX];
+fd = open("/path/to/dir", O_TMPFILE | O_RDWR,
+ S_IRUSR | S_IWUSR);
+
+/* File I/O on 'fd'... */
+
+snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd);
+linkat(AT_FDCWD, path, AT_FDCWD, "/path/for/file",
+ AT_SYMLINK_FOLLOW);
+.fi
+.in
+
+In this case, the \fBopen\fP() \fImode\fP argument determines the file permission
+mode, as with \fBO_CREAT\fP.
+
+Specifying \fBO_EXCL\fP in conjunction with \fBO_TMPFILE\fP prevents a temporary
+file from being linked into the filesystem in the above manner. (Note that
+the meaning of \fBO_EXCL\fP in this case is different from the meaning of
+\fBO_EXCL\fP otherwise.)
+
+
+.\" Inspired by http://lwn.net/Articles/559147/
+There are two main use cases for \fBO_TMPFILE\fP:
+.RS
+.IP * 3
+Improved \fBtmpfile\fP(3) functionality: race\-free creation of temporary files
+that (1) are automatically deleted when closed; (2) can never be reached via
+any pathname; (3) are not subject to symlink attacks; and (4) do not require
+the caller to devise unique names.
+.IP *
+Creating a file that is initially invisible, which is then populated with
+data and adjusted to have appropriate filesystem attributes (\fBchown\fP(2),
+\fBchmod\fP(2), \fBfsetxattr\fP(2), etc.) before being atomically linked into the
+filesystem in a fully formed state (using \fBlinkat\fP(2) as described above).
+.RE
+.IP
+.\" commit 99b6436bc29e4f10e4388c27a3e4810191cc4788
+.\" commit ab29743117f9f4c22ac44c13c1647fb24fb2bafe
+\fBO_TMPFILE\fP requires support by the underlying filesystem; only a subset of
+Linux filesystems provide that support. In the initial implementation,
+support was provided in the ex2, ext3, ext4, UDF, Minix, and shmem
+filesystems. XFS support was added in Linux 3.15.
+.TP
+\fBO_TRUNC\fP
+ファイルが既に存在し、通常ファイルであり、 アクセスモードで書き込みが許可されている (つまり、 \fBO_RDWR\fP または \fBO_WRONLY\fP
+の) 場合、長さ 0 に切り詰め (truncate) られる。 ファイルが FIFO または端末デバイスファイルの場合、 \fBO_TRUNC\fP
+フラグは無視される。 それ以外の場合、 \fBO_TRUNC\fP の効果は未定義である。
+.SS creat()
+\fBcreat\fP() は \fIflags\fP に \fBO_CREAT|O_WRONLY|O_TRUNC\fP を指定して \fBopen\fP()
+を行うのと等価である。
+.SS openat()
+\fBopenat\fP() システムコールは \fBopen\fP() と全く同様に動作するが、以下で説明する点が異なる。
+
+\fIpathname\fP で指定されたパス名が相対パスの場合、このパス名はファイルディスクリプター \fIdirfd\fP
+が参照するディレクトリに対する相対パスと解釈される (\fBopen\fP()
+に相対パス名を渡した場合のように、呼び出したプロセスのカレントワーキングディレクトリに対する相対パスではない)。
-.\"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
-¤òÊÖ¤·¤Æ¤¤¤¿¡£
+\fIpathname\fP で指定されたパス名が相対パスで、 \fIdirfd\fP が特別な値 \fBAT_FDCWD\fP の場合、 (\fBopen\fP()
+と同様に) \fIpathname\fP は呼び出したプロセスのカレントワーキングディレクトリに対する相対パスと解釈される。
+
+\fIpathname\fP で指定されたパス名が絶対パスの場合、 \fIdirfd\fP は無視される。
+.SH 返り値
+\fBopen\fP(), \fBopenat\fP(), \fBcreat\fP() は新しいファイルディスクリプタを返す。 エラーが発生した場合は \-1 を返す
+(その場合は \fIerrno\fP が適切に設定される)。
+.SH エラー
+\fBopen\fP(), \fBopenat\fP(), and \fBcreat\fP() can fail with the following errors:
+.TP
+\fBEACCES\fP
+ファイルに対する要求されたアクセスが許されていないか、 \fIpathname\fP のディレクトリ部分の何れかのディレクトリに検索許可がなかった。
+またはファイルが存在せず、親ディレクトリへの書き込み許可がなかった。 (\fBpath_resolution\fP(7) も参照すること。)
+.TP
+\fBEDQUOT\fP
+\fBO_CREAT\fP が指定された場合で、そのファイルが存在せず、ディスクブロックか inode がそのファイルシステムのユーザクォータに達していた。
+.TP
+\fBEEXIST\fP
+\fIpathname\fP は既に存在し、 \fBO_CREAT\fP と \fBO_EXCL\fP が使用された。
+.TP
+\fBEFAULT\fP
+\fIpathname\fP がアクセス可能なアドレス空間の外を指している。
+.TP
+\fBEFBIG\fP
+\fBEOVERFLOW\fP 参照。
+.TP
+\fBEINTR\fP
+遅いデバイス (例えば FIFO、 \fBfifo\fP(7) 参照) のオープンが完了するのを待って停止している間に
+システムコールがシグナルハンドラにより割り込まれた。 \fBsignal\fP(7) 参照。
+.TP
+\fBEINVAL\fP
+ファイルシステムが \fBO_DIRECT\fP フラグをサポートしていない。 詳細は\fB注意\fPを参照。
+.TP
+\fBEINVAL\fP
+.\" In particular, __O_TMPFILE instead of O_TMPFILE
+\fIflags\fP に無効な値が入っている。
+.TP
+\fBEINVAL\fP
+\fIflags\fP に \fBO_TMPFILE\fP が指定されたが、 \fBO_WRONLY\fP も \fBO_RDWR\fP も指定されていなかった。
+.TP
+\fBEISDIR\fP
+\fIpathname\fP はディレクトリを参照しており、書き込み要求が含まれていた (つまり \fBO_WRONLY\fP または \fBO_RDWR\fP
+が設定されている)。
+.TP
+\fBEISDIR\fP
+\fIpathname\fP refers to an existing directory, \fBO_TMPFILE\fP and one of
+\fBO_WRONLY\fP or \fBO_RDWR\fP were specified in \fIflags\fP, but this kernel version
+does not provide the \fBO_TMPFILE\fP functionality.
+.TP
+\fBELOOP\fP
+\fIpathname\fP を解決する際に遭遇したシンボリックリンクが多過ぎる。
+.TP
+\fBELOOP\fP
+\fIpathname\fP was a symbolic link, and \fIflags\fP specified \fBO_NOFOLLOW\fP but
+not \fBO_PATH\fP.
+.TP
+\fBEMFILE\fP
+プロセスがオープンしているファイル数がすでに最大数に達している。
+.TP
+\fBENAMETOOLONG\fP
+\fIpathname\fP が長過ぎる。
+.TP
+\fBENFILE\fP
+オープンされているファイルの総数がシステムの制限に達している。
+.TP
+\fBENODEV\fP
+\fIpathname\fP がデバイススペシャルファイルを参照しており、対応するデバイスが存在しない。 (これは Linux
+カーネルのバグであり、この場合には \fBENXIO\fP が返されるべきである)
+.TP
+\fBENOENT\fP
+\fBO_CREAT\fP が設定されておらず、かつ指定されたファイルが存在しない。 または、 \fIpathname\fP のディレクトリ部分が存在しないか壊れた
+(dangling) シンボリックリンクである。
+.TP
+\fBENOENT\fP
+\fIpathname\fP refers to a nonexistent directory, \fBO_TMPFILE\fP and one of
+\fBO_WRONLY\fP or \fBO_RDWR\fP were specified in \fIflags\fP, but this kernel version
+does not provide the \fBO_TMPFILE\fP functionality.
+.TP
+\fBENOMEM\fP
+十分なカーネルメモリーがない。
+.TP
+\fBENOSPC\fP
+\fIpathname\fP を作成する必要があるが、 \fIpathname\fP を含んでいるデバイスに新しいファイルのための空き容量がない。
+.TP
+\fBENOTDIR\fP
+\fIpathname\fP に含まれるディレクトリ部分のどれかが実際にはディレクトリでない。 または \fBO_DIRECTORY\fP が指定されており、
+\fIpathname\fP がディレクトリでない。
+.TP
+\fBENXIO\fP
+\fBO_NONBLOCK\fP | \fBO_WRONLY\fP が設定されており、指定したファイルが FIFO で
+そのファイルを読み込みのためにオープンしているプロセスが存在しない。 または、ファイルがデバイススペシャルファイルで 対応するデバイスが存在しない。
+.TP
+\fBEOPNOTSUPP\fP
+\fIpathname\fP を含んでいるファイルシステムが \fBO_TMPFILE\fP をサポートしていない。
+.TP
+\fBEOVERFLOW\fP
.\" 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 to obtain their definitions.
-¥Õ¥é¥°
-.BR O_DIRECTORY ,
-.BR O_NOATIME ,
-.B O_NOFOLLOW
-¤Ï Linux ÆÃͤΤâ¤Î¤Ç¤¢¤ê¡¢
-¤³¤ì¤é¤Î¥Õ¥é¥°¤ÎÄêµÁ¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢
-.B _GNU_SOURCE
-¤òÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
+\fIpathname\fP が参照しているのが、大き過ぎてオープンできない通常のファイルである。 通常、このエラーが発生するは、32
+ビットプラットフォーム上で \fI\-D_FILE_OFFSET_BITS=64\fP を指定せずにコンパイルされたアプリケーションが、ファイルサイズが
+\fI(2<31)\-1\fP ビットを超えるファイルを開こうとした場合である。 上記の \fBO_LARGEFILE\fP も参照。 これは
+POSIX.1\-2001 で規定されているエラーである。 2.6.24 より前のカーネルでは、Linux はこの場合にエラー \fBEFBIG\fP
+を返していた。
+.TP
+\fBEPERM\fP
+.\" Strictly speaking, it's the filesystem UID... (MTK)
+\fBO_NOATIME\fP フラグが指定されたが、呼び出し元の実効ユーザー ID が ファイルの所有者と一致せず、かつ呼び出し元に特権
+(\fBCAP_FOWNER\fP) がない。
+.TP
+\fBEROFS\fP
+\fIpathname\fP が読み込み専用のファイルシステム上のファイルを参照しており、 書き込みアクセスが要求された。
+.TP
+\fBETXTBSY\fP
+\fIpathname\fP が現在実行中の実行イメージを参照しており、書き込みが要求された。
+.TP
+\fBEWOULDBLOCK\fP
+\fBO_NONBLOCK\fP フラグが指定されたが、そのファイルには矛盾するリースが設定されていた (\fBfcntl\fP(2) 参照)。
+.PP
+\fBopenat\fP() では以下のエラーも発生する。
+.TP
+\fBEBADF\fP
+\fIdirfd\fP が有効なファイルディスクリプタではない。
+.TP
+\fBENOTDIR\fP
+\fIpathname\fP が相対パスで、 \fIdirfd\fP がディレクトリ以外のファイルを参照しているファイルディスクリプタである。
+.SH バージョン
+\fBopenat\fP() はカーネル 2.6.16 で Linux に追加された。 ライブラリによるサポートはバージョン 2.4 で glibc
+に追加された。
+.SH 準拠
+\fBopen\fP(), \fBcreat\fP() SVr4, 4.3BSD, POSIX.1\-2001, POSIX.1\-2008.
-.\"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 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
+\fBopenat\fP(): POSIX.1\-2008.
-.\"O .B O_DIRECT
-.\"O is not specified in POSIX; one has to define
-.\"O .B _GNU_SOURCE
-.\"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)
-¤Î¤¿¤á¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¡¢
-¥Ç¥Ð¥¤¥¹¤ò¥ª¡¼¥×¥ó¤¹¤ë¤È¤¤Ë¤è¤¯ÍѤ¤¤é¤ì¤ë¡£
+フラグ \fBO_DIRECT\fP, \fBO_NOATIME\fP, \fBO_PATH\fP, \fBO_TMPFILE\fP は Linux 特有のものである。
+これらのフラグの定義を得るためには \fB_GNU_SOURCE\fP を定義しなければならない。
+
+The \fBO_CLOEXEC\fP, \fBO_DIRECTORY\fP, and \fBO_NOFOLLOW\fP flags are not specified
+in POSIX.1\-2001, but are specified in POSIX.1\-2008. Since glibc 2.12, one
+can obtain their definitions by defining either \fB_POSIX_C_SOURCE\fP with a
+value greater than or equal to 200809L or \fB_XOPEN_SOURCE\fP with a value
+greater than or equal to 700. In glibc 2.11 and earlier, one obtains the
+definitions by defining \fB_GNU_SOURCE\fP.
+
+As noted in \fBfeature_test_macros\fP(7), feature test macros such as
+\fB_POSIX_C_SOURCE\fP, \fB_XOPEN_SOURCE\fP, and \fB_GNU_SOURCE\fP must be defined
+before including \fIany\fP header files.
+.SH 注意
+Linux では、 \fBO_NONBLOCK\fP フラグは、 open を実行したいが read または write を実行する意図は
+必ずしもないことを意味する。 これは \fBioctl\fP(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
-¤Ë±Æ¶Á¤¹¤ë¡£
+\fBO_RDONLY | O_TRUNC\fP の影響は未定義であり、その動作は実装によって異なる。 多くのシステムではファイルは実際に切り詰められる。
-.\"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 filesystems 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 ()
-¤¬ÊÖ¤ë¤Þ¤Ç¤Ë¡¢¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¤Î¥Ç¡¼¥¿¤È¤½¤Î¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë
-ɬÍפʥ᥿¥Ç¡¼¥¿¤À¤±¤¬¥Ç¥£¥¹¥¯¤Ë½ñ¤¹þ¤Þ¤ì¤Æ¤¤¤ì¤Ð¤è¤¤¡£
+\fBopen\fP() はスペシャルファイルをオープンすることができるが、 \fBcreat\fP() でスペシャルファイルを作成できない点に注意すること。
+代わりに \fBmknod\fP(2) を使用する。
-.\"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 ¥Þ¥Ã¥Ô¥ó¥°¤¬¹Ô¤ï¤ì¤ë¤¿¤á¤Ç¤¢¤ë¡£
+.\"
+.\"
+ファイルが新しく作成されると、 ファイルの \fIst_atime\fP, \fIst_ctime\fP, \fIst_mtime\fP フィールド
+(それぞれ最終アクセス時刻、最終状態変更時刻、最終修正時刻である。 \fBstat\fP(2) 参照) が現在時刻に設定される。 さらに親ディレクトリの
+\fIst_ctime\fP と \fIst_mtime\fP も現在時刻に設定される。 それ以外の場合で、O_TRUNC フラグでファイルが修正されたときは、
+ファイルの \fIst_ctime\fP と \fIst_mtime\fP フィールドが現在時刻に設定される。
+.SS "Synchronized I/O"
+The POSIX.1\-2008 "synchronized I/O" option specifies different variants of
+synchronized I/O, and specifies the \fBopen\fP() flags \fBO_SYNC\fP, \fBO_DSYNC\fP,
+and \fBO_RSYNC\fP for controlling the behavior. Regardless of whether an
+implementation supports this option, it must at least support the use of
+\fBO_SYNC\fP for regular files.
+
+Linux implements \fBO_SYNC\fP and \fBO_DSYNC\fP, but not \fBO_RSYNC\fP. (Somewhat
+incorrectly, glibc defines \fBO_RSYNC\fP to have the same value as \fBO_SYNC\fP.)
+
+\fBO_SYNC\fP provides synchronized I/O \fIfile\fP integrity completion, meaning
+write operations will flush data and all associated metadata to the
+underlying hardware. \fBO_DSYNC\fP provides synchronized I/O \fIdata\fP integrity
+completion, meaning write operations will flush data to the underlying
+hardware, but will only flush metadata updates that are required to allow a
+subsequent read operation to complete successfully. Data integrity
+completion can reduce the number of disk operations that are required for
+applications that don't need the guarantees of file integrity completion.
+
+To understand the difference between the the two types of completion,
+consider two pieces of file metadata: the file last modification timestamp
+(\fIst_mtime\fP) and the file length. All write operations will update the
+last file modification timestamp, but only writes that add data to the end
+of the file will change the file length. The last modification timestamp is
+not needed to ensure that a read completes successfully, but the file length
+is. Thus, \fBO_DSYNC\fP would only guarantee to flush updates to the file
+length metadata (whereas \fBO_SYNC\fP would also always flush the last
+modification timestamp metadata).
+
+Before Linux 2.6.33, Linux implemented only the \fBO_SYNC\fP flag for
+\fBopen\fP(). However, when that flag was specified, most filesystems actually
+provided the equivalent of synchronized I/O \fIdata\fP integrity completion
+(i.e., \fBO_SYNC\fP was actually implemented as the equivalent of \fBO_DSYNC\fP).
+
+.\"
+.\"
+Since Linux 2.6.33, proper \fBO_SYNC\fP support is provided. However, to
+ensure backward binary compatibility, \fBO_DSYNC\fP was defined with the same
+value as the historical \fBO_SYNC\fP, and \fBO_SYNC\fP was defined as a new
+(two\-bit) flag value that includes the \fBO_DSYNC\fP flag value. This ensures
+that applications compiled against new headers get at least \fBO_DSYNC\fP
+semantics on pre\-2.6.33 kernels.
+.SS NFS
+NFS を実現しているプロトコルには多くの不備があり、特に \fBO_SYNC\fP と \fBO_NDELAY\fP に影響する。
+
+.\"
+.\"
+UID マッピングを使用している NFS ファイルシステムでは、 \fBopen\fP() がファイルディスクリプタを返した場合でも \fBread\fP(2)
+が \fBEACCES\fP で拒否される場合がある。 これはクライアントがアクセス許可のチェックを行って \fBopen\fP()
+を実行するが、読み込みや書き込みの際には サーバーで UID マッピングが行われるためである。
+.SS "File access mode"
+「アクセスモード」の値 \fBO_RDONLY\fP, \fBO_WRONLY\fP, \fBO_RDWR\fP は、 \fIflags\fP
+に指定できる他の値と違い、個々のビットを指定するものではなく、 これらの値は \fIflags\fP の下位 2 ビットを定義する。 \fBO_RDONLY\fP,
+\fBO_WRONLY\fP, \fBO_RDWR\fP はそれぞれ 0, 1, 2 に定義されている。 言い換えると、 \fBO_RDONLY |
+O_WRONLY\fP の組み合わせは論理的に間違いであり、確かに \fBO_RDWR\fP と同じ意味ではない。
+
+.\" 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
+.\"
+.\"
+Linux では、特別な、非標準なアクセスモードとして 3 (バイナリでは 11) が 予約されており \fIflags\fP に指定できる。
+このアクセスモードを指定すると、ファイルの読み出し/書き込み許可をチェックし、 読み出しにも書き込みにも使用できないディスクリプタを返す。
+この非標準のアクセスモードはいくつかの Linux ドライバで、デバイス固有の \fBioctl\fP(2)
+操作にのみ使用されるディスクリプタを返すために使われている。
+.SS "Rationale for openat() and other directory file descriptor APIs"
+\fBopenat\fP() and the other system calls and library functions that take a
+directory file descriptor argument (i.e., \fBfaccessat\fP(2),
+\fBfanotify_mark\fP(2), \fBfchmodat\fP(2), \fBfchownat\fP(2), \fBfstatat\fP(2),
+\fBfutimesat\fP(2), \fBlinkat\fP(2), \fBmkdirat\fP(2), \fBmknodat\fP(2),
+\fBname_to_handle_at\fP(2), \fBreadlinkat\fP(2), \fBrenameat\fP(2), \fBsymlinkat\fP(2),
+\fBunlinkat\fP(2), \fButimensat\fP(2) \fBmkfifoat\fP(3), and \fBscandirat\fP(3)) are
+supported for two reasons. Here, the explanation is in terms of the
+\fBopenat\fP() call, but the rationale is analogous for the other interfaces.
+
+First, \fBopenat\fP() allows an application to avoid race conditions that
+could occur when using \fBopen\fP() to open files in directories other than
+the current working directory. These race conditions result from the fact
+that some component of the directory prefix given to \fBopen\fP() could be
+changed in parallel with the call to \fBopen\fP(). Such races can be avoided
+by opening a file descriptor for the target directory, and then specifying
+that file descriptor as the \fIdirfd\fP argument of \fBopenat\fP().
-.\"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
-¥Õ¥£¡¼¥ë¥É¤¬¸½ºß»þ¹ï¤ËÀßÄꤵ¤ì¤ë¡£
+.\"
+.\"
+Second, \fBopenat\fP() allows the implementation of a per\-thread "current
+working directory", via file descriptor(s) maintained by the application.
+(This functionality can also be obtained by tricks based on the use of
+\fI/proc/self/fd/\fPdirfd, but less efficiently.)
.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
-Ì¿Îá¤Ç¤¢¤ë¡£
+\fBO_DIRECT\fP フラグを使用する場合、ユーザ空間バッファの長さやアドレス、 I/O
+のファイルオフセットに関してアラインメントの制限が課されることがある。 Linux では、アラインメントの制限はファイルシステムやカーネルのバージョンに
+よって異なり、全く制限が存在しない場合もある。 しかしながら、現在のところ、指定されたファイルやファイルシステムに対して
+こうした制限があるかを見つけるための、アプリケーション向けのインタフェースで ファイルシステム非依存のものは存在しない。
+いくつかのファイルシステムでは、制限を確認するための独自のインタフェースが 提供されている。例えば、 \fBxfsctl\fP(3) の
+\fBXFS_IOC_DIOINFO\fP 命令である。
.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 ¥Ð¥¤¥È¤´¤È¤Î¶³¦¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ì¤Ð½¼Ê¬¤Ç¤¢¤ë¡£
+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 ¤âƱ¤¸Ì¾Á°¤Î¥Õ¥é¥°¤òƳÆþ¤·¤¿¤¬¡¢¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤Ï¤Ê¤¤¡£
+メモリバッファがプライベートマッピング (\fBmmap\fP(2) の \fBMAP_PRIVATE\fP
+フラグで作成されたマッピング) の場合には、\fBO_DIRECT\fP I/O は
+\fBfork\fP(2) システムコールと同時に決して実行すべきではない
+(プライベートマッピングには、ヒープ領域に割り当てられたメモリや静的に
+割り当てたバッファも含まれる)。非同期 I/O インターフェース (AIO) 経由
+やプロセス内の他のスレッドから発行された、このような I/O は、
+\fBfork\fP(2) が呼び出される前に完了されるべきである。
+そうしなかった場合、データ破壊や、親プロセスや子プロセスでの予期しない
+動作が起こる可能性がある。
+\fBO_DIRECT\fP I/O 用のメモリバッファが \fBshmat\fP(2) や\fBMAP_SHARED\fP フラグ
+付きの \fBmmap\fP(2) で作成された場合には、この制限はあてはまらない。
+\fBmadvise\fP(2) でメモリバッファにアドバイス \fBMADV_DONTFORK\fP が設定され
+ている場合にも、この制限はあてはまらない(\fBMADV_DONTFORK\fP はそのメモリ
+バッファが \fBfork\fP(2) 後に子プロセスからは利用できないことを保証するも
+のである)。
.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
-¤Ç¼ºÇÔ¤¹¤ë¡£
+\fBO_DIRECT\fP フラグは SGI IRIX で導入された。SGI IRIX にも Linux 2.4 と同様の (ユーザーバッファの)
+アラインメントの制限がある。 また、IRIX には適切な配置とサイズを取得するための \fBfcntl\fP(2) コールがある。 FreeBSD 4.x
+も同じ名前のフラグを導入したが、アラインメントの制限はない。
.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 )
-¤òº®¤¼¤Æ»È¤¦¤Î¤âÈò¤±¤ë¤Ù¤¤Ç¤¢¤ë¡£
+\fBO_DIRECT\fP が Linux でサポートされたのは、カーネルバージョン 2.4.10 である。 古い Linux
+カーネルは、このフラグを単に無視する。 \fBO_DIRECT\fP フラグをサポートしていないファイルシステムもあり、その場合は、 \fBO_DIRECT\fP
+を使用すると \fBopen\fP() は \fBEINVAL\fP で失敗する。
.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
-¤Ç¤Î¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤Ï¤Ê¤¤¡£
+アプリケーションは、同じファイル、 特に同じファイルの重複するバイト領域に対して、 \fBO_DIRECT\fP と通常の I/O
+を混ぜて使うのは避けるべきである。 ファイルシステムがこのような状況において一貫性の問題を正しく 扱うことができる場合であっても、全体の I/O
+スループットは どちらか一方を使用するときと比べて低速になるであろう。 同様に、アプリケーションは、同じファイルに対して \fBmmap\fP(2) と直接
+I/O (\fBO_DIRECT\fP) を混ぜて使うのも避けるべきである。
+.LP
+NFS で \fBO_DIRECT\fP を使った場合の動作はローカルのファイルシステムの場合と違う。
+古いカーネルや、ある種の設定でコンパイルされたカーネルは、 \fBO_DIRECT\fP と NFS の組み合わせをサポートしていないかもしれない。 NFS
+プロトコル自体はサーバにフラグを渡す機能は持っていないので、 \fBO_DIRECT\fP I/O
+はクライアント上のページキャッシュをバイパスするだけになり、 サーバは I/O をキャッシュしているかもしれない。 クライアントは、
+\fBO_DIRECT\fP の同期機構を保持するため、サーバに対して I/O を同期して行うように依頼する。 サーバによっては、こうした状況下、特に I/O
+サイズが小さい場合に 性能が大きく劣化する。 また、サーバによっては、I/O が安定したストレージにまで行われたと、
+クライアントに対して嘘をつくものもある。 これは、サーバの電源故障が起こった際にデータの完全性が保たれない
+危険は少しあるが、性能面での不利な条件を回避するために行われている。 Linux の NFS クライアントでは \fBO_DIRECT\fP 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
-¤ò¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï̵¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ëÀǽ¸þ¾å¤Î¤¿¤á¤Î¥ª¥×¥·¥ç¥ó¤È
-¹Í¤¨¤Æ¤ª¤¯¤Î¤¬¤è¤¤¤Ç¤¢¤í¤¦¡£
+まとめると、 \fBO_DIRECT\fP は、注意して使うべきであるが、強力なツールとなる可能性を持っている。 アプリケーションは \fBO_DIRECT\fP
+をデフォルトでは無効になっている性能向上のためのオプションと 考えておくのがよいであろう。
.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
+「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)
-¤ò»ÈÍѤ¹¤ë¤³¤È¡£
+.SH バグ
.\" 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 feature_test_macros (7),
-.BR fifo (7),
-.BR path_resolution (7),
-.BR symlink (7)
+現在のところ、 \fBopen\fP() の呼び出し時に \fBO_ASYNC\fP を指定してシグナル駆動 I/O を有効にすることはできない。
+このフラグを有効にするには \fBfcntl\fP(2) を使用すること。
+
+One must check for two different error codes, \fBEISDIR\fP and \fBENOENT\fP, when
+trying to determine whether the kernel supports \fBO_TMPFILE\fP functionality.
+.SH 関連項目
+\fBchmod\fP(2), \fBchown\fP(2), \fBclose\fP(2), \fBdup\fP(2), \fBfcntl\fP(2), \fBlink\fP(2),
+\fBlseek\fP(2), \fBmknod\fP(2), \fBmmap\fP(2), \fBmount\fP(2), \fBopen_by_name_at\fP(2),
+\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.65 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。