OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man2 / open.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\"                               1993 Michael Haardt, Ian Jackson.
5 .\"                               2008 Greg Banks
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified 1994-08-21 by Michael Haardt
29 .\" Modified 1996-04-13 by Andries Brouwer <aeb@cwi.nl>
30 .\" Modified 1996-05-13 by Thomas Koenig
31 .\" Modified 1996-12-20 by Michael Haardt
32 .\" Modified 1999-02-19 by Andries Brouwer <aeb@cwi.nl>
33 .\" Modified 1998-11-28 by Joseph S. Myers <jsm28@hermes.cam.ac.uk>
34 .\" Modified 1999-06-03 by Michael Haardt
35 .\" Modified 2002-05-07 by Michael Kerrisk <mtk.manpages@gmail.com>
36 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" 2004-12-08, mtk, reordered flags list alphabetically
38 .\" 2004-12-08, Martin Pool <mbp@sourcefrog.net> (& mtk), added O_NOATIME
39 .\" 2007-09-18, mtk, Added description of O_CLOEXEC + other minor edits
40 .\" 2008-01-03, mtk, with input from Trond Myklebust
41 .\"     <trond.myklebust@fys.uio.no> and Timo Sirainen <tss@iki.fi>
42 .\"     Rewrite description of O_EXCL.
43 .\" 2008-01-11, Greg Banks <gnb@melbourne.sgi.com>: add more detail
44 .\"     on O_DIRECT.
45 .\" 2008-02-26, Michael Haardt: Reorganized text for O_CREAT and mode
46 .\"
47 .\" FIXME . Apr 08: The next POSIX revision has O_EXEC, O_SEARCH, and
48 .\" O_TTYINIT.  Eventually these may need to be documented.  --mtk
49 .\" FIXME Linux 2.6.33 has O_DSYNC, and a hiddden __O_SYNC.
50 .\"
51 .\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
52 .\"         all rights reserved.
53 .\" Translated 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
54 .\" Updated 2001-05-25, Yuichi SATO <ysato444@yahoo.co.jp>
55 .\" Updated & Modified 2002-01-02, Yuichi SATO
56 .\" Updated & Modified 2002-07-07, Yuichi SATO
57 .\" Updated & Modified 2002-09-19, Yuichi SATO
58 .\" Updated & Modified 2003-07-30, Yuichi SATO
59 .\" Updated & Modified 2003-11-27, Yuichi SATO
60 .\" Updated & Modified 2005-01-01, Yuichi SATO
61 .\" Updated & Modified 2005-09-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
62 .\" Updated & Modified 2005-10-14, Akihiro MOTOKI
63 .\" Updated & Modified 2006-01-18, Akihiro MOTOKI
64 .\" Updated & Modified 2006-04-15, Akihiro MOTOKI, LDP v2.29
65 .\" Updated 2007-01-07, Akihiro MOTOKI, LDP v2.43
66 .\" Updated 2007-05-01, Akihiro MOTOKI, LDP v2.46
67 .\" Updated 2007-10-12, Akihiro MOTOKI, LDP v2.66
68 .\" Updated 2008-02-12, Akihiro MOTOKI, LDP v2.77
69 .\" Updated 2008-04-04, Akihiro MOTOKI, LDP v2.79
70 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
71 .\" Updated 2010-04-23, Akihiro MOTOKI, LDP v3.24
72 .\"
73 .\"WORD:        descriptor              ¥Ç¥£¥¹¥¯¥ê¥×¥¿
74 .\"WORD:        file description        ¥Õ¥¡¥¤¥ëµ­½Ò
75 .\"WORD:        open                    ¥ª¡¼¥×¥ó
76 .\"WORD:        create                  ºîÀ®
77 .\"WORD:        file offset             ¥Õ¥¡¥¤¥ë¡¦¥ª¥Õ¥»¥Ã¥È
78 .\"WORD:        controling terminal     À©¸æüËö
79 .\"WORD:        non-blocking I/O        ÈóÄä»ß I/O
80 .\"WORD:        synchronous I/O         Æ±´ü I/O
81 .\"WORD:        permission              µö²Ä
82 .\"WORD:        user                    ¥æ¡¼¥¶¡¼
83 .\"WORD:        owner                   ½êÍ­¼Ô
84 .\"WORD:        group                   ¥°¥ë¡¼¥×
85 .\"WORD:        other                   Â¾¿Í
86 .\"WORD:        kernel                  ¥«¡¼¥Í¥ë
87 .\"WORD:        symbolic link           ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯
88 .\"WORD:        dangling symbolic link  ²õ¤ì¤¿¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯
89 .\"WORD:        file creation flag      ¥Õ¥¡¥¤¥ëºîÀ®¥Õ¥é¥°
90 .\"WORD:        file status flag        ¥Õ¥¡¥¤¥ë¾õÂ֥ե饰
91 .\"
92 .TH OPEN 2 2009-09-20 "Linux" "Linux Programmer's Manual"
93 .\"O .SH NAME
94 .SH Ì¾Á°
95 .\"O open, creat \- open and possibly create a file or device
96 open, creat \- ¥Õ¥¡¥¤¥ë¤ä¥Ç¥Ð¥¤¥¹¤Î¥ª¡¼¥×¥ó¡¢ºîÀ®¤ò¹Ô¤¦
97 .\"O .SH SYNOPSIS
98 .SH ½ñ¼°
99 .nf
100 .B #include <sys/types.h>
101 .B #include <sys/stat.h>
102 .B #include <fcntl.h>
103 .sp
104 .BI "int open(const char *" pathname ", int " flags );
105 .BI "int open(const char *" pathname ", int " flags ", mode_t " mode );
106
107 .BI "int creat(const char *" pathname ", mode_t " mode );
108 .fi
109 .\"O .SH DESCRIPTION
110 .SH ÀâÌÀ
111 .\"O Given a
112 .\"O .I pathname
113 .\"O for a file,
114 .\"O .BR open ()
115 .\"O returns a file descriptor, a small, nonnegative integer
116 .\"O for use in subsequent system calls
117 .\"O .RB ( read "(2), " write "(2), " lseek "(2), " fcntl "(2), etc.)."
118 .\"O The file descriptor returned by a successful call will be
119 .\"O the lowest-numbered file descriptor not currently open for the process.
120 ¥Õ¥¡¥¤¥ë¤Î
121 .I pathname
122 ¤òÍ¿¤¨¤ë¤È¡¢
123 .BR open ()
124 ¤Ï¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
125 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¤³¤Î¸å¤Ë³¤¯¥·¥¹¥Æ¥à¥³¡¼¥ë
126 .RB ( read "(2), " write "(2), " lseek "(2), " fcntl "(2) ¤Ê¤É)"
127 ¤Ç»ÈÍѤµ¤ì¤ë¾®¤µ¤ÊÈóÉé¤ÎÀ°¿ô¤Ç¤¢¤ë¡£
128 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬À®¸ù¤·¤¿¾ì¹ç¤ËÊÖ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
129 ¤½¤Î¥×¥í¥»¥¹¤¬¤½¤Î»þÅÀ¤Ç¥ª¡¼¥×¥ó¤·¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
130 ¤¦¤ÁºÇ¾®¤Î¿ô»ú¤Î¤â¤Î¤È¤Ê¤ë¡£
131 .PP
132 .\"O By default, the new file descriptor is set to remain open across an
133 .\"O .BR execve (2)
134 .\"O (i.e., the
135 .\"O .B FD_CLOEXEC
136 .\"O file descriptor flag described in
137 .\"O .BR fcntl (2)
138 .\"O is initially disabled; the Linux-specific
139 .\"O .B O_CLOEXEC
140 .\"O flag, described below, can be used to change this default).
141 .\"O The file offset is set to the beginning of the file (see
142 .\"O .BR lseek (2)).
143 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¿·¤·¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
144 .BR execve (2)
145 ¤ò¼Â¹Ô¤·¤¿¸å¤â¥ª¡¼¥×¥ó¤µ¤ì¤¿¤Þ¤Þ¤È¤Ê¤ë (¤Ä¤Þ¤ê¡¢
146 .BR fcntl (2)
147 ¤ËÀâÌÀ¤¬¤¢¤ë
148 .B FD_CLOEXEC
149 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Õ¥é¥°¤ÏºÇ½é¤Ï̵¸ú¤Ç¤¢¤ë;
150 ¸å½Ò¤Î Linux ¸ÇÍ­¤Î¥Õ¥é¥°
151 .B O_CLOEXEC
152 ¤ò»È¤¦¤È¤³¤Î¥Ç¥Õ¥©¥ë¥È¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë)¡£
153 ¥Õ¥¡¥¤¥ë¡¦¥ª¥Õ¥»¥Ã¥È (file offset) ¤Ï¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤ËÀßÄꤵ¤ì¤ë
154 .RB ( lseek (2)
155 »²¾È)¡£
156 .PP
157 .\"O A call to
158 .\"O .BR open ()
159 .\"O creates a new
160 .\"O .IR "open file description" ,
161 .\"O an entry in the system-wide table of open files.
162 .BR open ()
163 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¡Ö¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¡×
164 .I "(open file description)"
165 ¤¬ºîÀ®¤µ¤ì¤ë¡£¥Õ¥¡¥¤¥ëµ­½Ò¤È¤Ï¡¢¥·¥¹¥Æ¥àÁ´ÂΤÎ
166 ¥ª¡¼¥×¥óÃæ¤Î¥Õ¥¡¥¤¥ë¤Î¥Æ¡¼¥Ö¥ë¤Î¥¨¥ó¥È¥ê¤Ç¤¢¤ë¡£
167 .\"O This entry records the file offset and the file status flags
168 .\"O (modifiable via the
169 .\"O .BR fcntl (2)
170 .\"O .B F_SETFL
171 .\"O operation).
172 .\"O A file descriptor is a reference to one of these entries;
173 .\"O this reference is unaffected if
174 .\"O .I pathname
175 .\"O is subsequently removed or modified to refer to a different file.
176 ¤³¤Î¥¨¥ó¥È¥ê¤Ï¡¢¥Õ¥¡¥¤¥ë¡¦¥ª¥Õ¥»¥Ã¥È¤È¥Õ¥¡¥¤¥ë¾õÂ֥ե饰
177 .RB ( fcntl (2)
178 .B F_SETFL
179 Áàºî¤Ë¤è¤êÊѹ¹²Äǽ) ¤¬ÊÝ»ý¤¹¤ë¡£
180 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¤³¤ì¤é¤Î¥¨¥ó¥È¥ê¤Î°ì¤Ä¤Ø¤Î»²¾È¤Ç¤¢¤ë¡£
181 ¤³¤Î¸å¤Ç
182 .I pathname
183 ¤¬ºï½ü¤µ¤ì¤¿¤ê¡¢Â¾¤Î¥Õ¥¡¥¤¥ë¤ò»²¾È¤¹¤ë¤è¤¦¤ËÊѹ¹¤µ¤ì¤¿¤ê¤·¤Æ¤â¡¢
184 ¤³¤Î»²¾È¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£
185 .\"O The new open file description is initially not shared
186 .\"O with any other process,
187 .\"O but sharing may arise via
188 .\"O .BR fork (2).
189 ¿·¤·¤¤¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¤ÏºÇ½é¤Ï¾¤Î¤É¤Î¥×¥í¥»¥¹¤È¤â
190 ¶¦Í­¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
191 .BR fork (2)
192 ¤Ç¶¦Í­¤¬µ¯¤³¤ë¾ì¹ç¤¬¤¢¤ë¡£
193 .PP
194 .\"O The argument
195 .\"O .I flags
196 .\"O must include one of the following
197 .\"O .IR "access modes" :
198 .\"O .BR O_RDONLY ", " O_WRONLY ", or " O_RDWR .
199 .\"O These request opening the file read-only, write-only, or read/write,
200 .\"O respectively.
201 °ú¤­¿ô
202 .I flags
203 ¤Ë¤Ï¡¢¥¢¥¯¥»¥¹¥â¡¼¥É
204 .BR O_RDONLY ", " O_WRONLY ", " O_RDWR
205 ¤Î¤É¤ì¤«¤Ò¤È¤Ä¤¬Æþ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
206 ¤³¤ì¤é¤Ï¤½¤ì¤¾¤ìÆɤ߹þ¤ßÀìÍÑ¡¢½ñ¤­¹þ¤ßÀìÍÑ¡¢Æɤ߽ñ¤­ÍѤË
207 ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë¤³¤È¤òÍ׵᤹¤ë¤â¤Î¤Ç¤¢¤ë¡£
208
209 .\"O In addition, zero or more file creation flags and file status flags
210 .\"O can be
211 .\"O .RI bitwise- or 'd
212 .\"O in
213 .\"O .IR flags .
214 ¤µ¤é¤Ë¡¢
215 .I flags
216 ¤Ë¤Ï¡¢¥Õ¥¡¥¤¥ëºîÀ®¥Õ¥é¥° (file creation flag) ¤È¥Õ¥¡¥¤¥ë¾õÂ֥ե饰
217 (file status flag) ¤ò 0 ¸Ä°Ê¾å¡Ö¥Ó¥Ã¥Èñ°Ì¤Î OR (bitwise-or)¡×¤Ç
218 »ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
219 .\"O The
220 .\"O .I file creation flags
221 .\"O are
222 .\"O .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", and " O_TRUNC .
223 .\"O The
224 .\"O .I file status flags
225 .\"O are all of the remaining flags listed below.
226 .I ¥Õ¥¡¥¤¥ëºîÀ®¥Õ¥é¥°
227 ¤Ï
228 .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC
229 ¤Ç¤¢¤ë¡£
230 .I ¥Õ¥¡¥¤¥ë¾õÂ֥ե饰
231 ¤Ï°Ê²¼¤Î¥ê¥¹¥È¤Î¤¦¤Á¾åµ­°Ê³°¤Î»Ä¤ê¤Î¤â¤Î¤Ç¤¢¤ë¡£
232 .\" FIXME . Actually is it true that the "file status flags" are all of the
233 .\" remaining flags listed below?  SUSv4 divides the flags into:
234 .\" * Access mode
235 .\" * File creation
236 .\" * File status
237 .\" * Other (O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW)
238 .\" though it's not clear what the difference between "other" and
239 .\" "File creation" flags is.  (I've raised an Aardvark to see if this
240 .\" can be clarified in SUSv4; 10 Oct 2008.)
241 .\"O The distinction between these two groups of flags is that
242 .\"O the file status flags can be retrieved and (in some cases)
243 .\"O modified using
244 .\"O .BR fcntl (2).
245 .\"O The full list of file creation flags and file status flags is as follows:
246 Æó¼ïÎà¤Î¥Õ¥é¥°¤Î°ã¤¤¤Ï¡¢¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤ÎÊý¤Ï
247 .BR fcntl (2)
248 ¤ò»È¤Ã¤Æ¤½¤ÎÆâÍƤò¼èÆÀ¤·¤¿¤ê (¾ì¹ç¤Ë¤è¤Ã¤Æ¤Ï) Êѹ¹¤·¤¿¤ê¤Ç¤­¤ëÅÀ¤Ë¤¢¤ë¡£
249 ¥Õ¥¡¥¤¥ëºîÀ®¥Õ¥é¥°¤È¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤ÎÁ´¥ê¥¹¥È¤ò°Ê²¼¤Ë¼¨¤¹:
250 .TP
251 .B O_APPEND
252 .\"O The file is opened in append mode.
253 .\"O Before each
254 .\"O .BR write (2),
255 .\"O the file offset is positioned at the end of the file,
256 .\"O as if with
257 .\"O .BR lseek (2).
258 ¥Õ¥¡¥¤¥ë¤òÄɲà(append) ¥â¡¼¥É¤Ç¥ª¡¼¥×¥ó¤¹¤ë¡£
259 Ëè²ó¤Î
260 .BR write (2)
261 ¤ÎÁ°¤Ë
262 .BR lseek (2)
263 ¤ò¹Ô¤Ã¤¿¤«¤Î¤è¤¦¤Ë¡¢¥Õ¥¡¥¤¥ë¡¦¥Ý¥¤¥ó¥¿¡¼¤ò¥Õ¥¡¥¤¥ë¤ÎºÇ¸å¤Ë°ÜÆ°¤¹¤ë¡£
264 .\"O .B O_APPEND
265 .\"O may lead to corrupted files on NFS file systems if more than one process
266 .\"O appends data to a file at once.
267 .\" For more background, see
268 .\" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=453946
269 .\" http://nfs.sourceforge.net/
270 .\"O This is because NFS does not support
271 .\"O appending to a file, so the client kernel has to simulate it, which
272 .\"O can't be done without a race condition.
273 NFS ¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤Ç¡¢
274 .B O_APPEND
275 ¤ò»ÈÍѤ¹¤ë¤È¡¢Ê£¿ô¤Î¥×¥í¥»¥¹¤¬¤Ò¤È¤Ä¤Î¥Õ¥¡¥¤¥ë¤ËƱ»þ¤Ë¥Ç¡¼¥¿¤òÄɲä·¤¿¾ì¹ç¡¢
276 ¥Õ¥¡¥¤¥ë¤¬²õ¤ì¤Æ¤·¤Þ¤¦¤³¤È¤¬¤¢¤ë¡£
277 ¤³¤ì¤Ï NFS ¤¬Äɲå⡼¥É¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¤¿¤á¡¢
278 ¥¯¥é¥¤¥¢¥ó¥È¤Î¥«¡¼¥Í¥ë (kernel) ¤¬¤½¤ì¤ò¥·¥ß¥å¥ì¡¼¥È¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤À¤¬¡¢
279 ¶¥¹ç¾õÂÖ¤òÈò¤±¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
280 .TP
281 .B O_ASYNC
282 .\"O Enable signal-driven I/O:
283 .\"O generate a signal
284 .\"O .RB ( SIGIO
285 .\"O by default, but this can be changed via
286 .\"O .BR fcntl (2))
287 .\"O when input or output becomes possible on this file descriptor.
288 ¥·¥°¥Ê¥ë¶îÆ° I/O (signal-driven I/O) ¤òÍ­¸ú¤Ë¤¹¤ë:
289 ¤³¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ø¤Î
290 ÆþÎϤޤ¿¤Ï½ÐÎϤ¬²Äǽ¤Ë¤Ê¤Ã¤¿¾ì¹ç¤Ë¡¢¥·¥°¥Ê¥ë¤òÀ¸À®¤¹¤ë
291 (¥Ç¥Õ¥©¥ë¥È¤Ï
292 .B SIGIO
293 ¤Ç¤¢¤ë¤¬¡¢
294 .BR fcntl (2)
295 ¤Ë¤è¤Ã¤ÆÊѹ¹²Äǽ¤Ç¤¢¤ë)¡£
296 .\"O This feature is only available for terminals, pseudo-terminals,
297 .\"O sockets, and (since Linux 2.6) pipes and FIFOs.
298 .\"O See
299 .\"O .BR fcntl (2)
300 .\"O for further details.
301 ¤³¤Îµ¡Ç½¤¬»ÈÍѲÄǽ¤Ê¤Î¤ÏüËö¡¢µ¿»÷üËö¡¢¥½¥±¥Ã¥È¤Î¤ß¤Ç¤¢¤ê¡¢
302 (Linux 2.6 °Ê¹ß¤Ç¤Ï) ¥Ñ¥¤¥×¤È FIFO ¤ËÂФ·¤Æ¤â»ÈÍѤǤ­¤ë¡£
303 ¤µ¤é¤Ë¾Ü¤·¤¤ÀâÌÀ¤Ï
304 .BR fcntl (2)
305 ¤ò»²¾È¤¹¤ë¤³¤È¡£
306 .TP
307 .\"O .BR O_CLOEXEC " (Since Linux 2.6.23)"
308 .BR O_CLOEXEC " (Linux 2.6.23 °Ê¹ß)"
309 .\"O Enable the close-on-exec flag for the new file descriptor.
310 ¿·¤·¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ close-on-exec ¥Õ¥é¥°¤òÍ­¸ú¤Ë¤¹¤ë¡£
311 .\"O Specifying this flag permits a program to avoid additional
312 .\"O .BR fcntl (2)
313 .\"O .B F_SETFD
314 .\"O operations to set the
315 .\"O .B FD_CLOEXEC
316 .\"O flag.
317 ¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢¥×¥í¥°¥é¥à¤Ï
318 .B FD_CLOEXEC
319 ¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¤¿¤á¤Î
320 .BR fcntl (2)
321 .B F_SETFD
322 Áàºî¤òÊÌÅӸƤӽФ¹É¬Íפ¬¤Ê¤¯¤Ê¤ë¡£
323 .\"O Additionally,
324 .\"O use of this flag is essential in some multithreaded programs
325 .\"O since using a separate
326 .\"O .BR fcntl (2)
327 .\"O .B F_SETFD
328 .\"O operation to set the
329 .\"O .B FD_CLOEXEC
330 .\"O flag does not suffice to avoid race conditions
331 .\"O where one thread opens a file descriptor at the same
332 .\"O time as another thread does a
333 .\"O .BR fork (2)
334 .\"O plus
335 .\"O .BR execve (2).
336 ¤Þ¤¿¡¢¤¢¤ë¼ï¤Î¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Î¥×¥í¥°¥é¥à¤Ï¤³¤Î¥Õ¥é¥°¤Î»ÈÍѤÏ
337 ÉԲķç¤Ç¤¢¤ë¡£¤Ê¤¼¤Ê¤é¡¢¸ÄÊ̤Ë
338 .B FD_CLOEXEC
339 ¥Õ¥é¥°¤òÀßÄꤹ¤ë
340 .BR fcntl (2)
341 .B F_SETFD
342 Áàºî¤ò¸Æ¤Ó½Ð¤·¤¿¤È¤·¤Æ¤â¡¢¤¢¤ë¥¹¥ì¥Ã¥É¤¬¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò
343 ¥ª¡¼¥×¥ó¤¹¤ë¤Î¤ÈƱ»þ¤ËÊ̤Υ¹¥ì¥Ã¥É¤¬
344 .BR fork (2)
345 ¤È
346 .BR execve (2)
347 ¤ò¼Â¹Ô¤¹¤ë¤È¤¤¤¦¶¥¹ç¾ò·ï¤òÈò¤±¤ë¤Î¤Ë¤Ï½½Ê¬¤Ç¤Ï¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
348 .\" This flag fixes only one form of the race condition;
349 .\" The race can also occur with, for example, descriptors
350 .\" returned by accept(), pipe(), etc.
351 .TP
352 .B O_CREAT
353 .\"O If the file does not exist it will be created.
354 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤«¤Ã¤¿¾ì¹ç¤ÏºîÀ® (create) ¤¹¤ë¡£
355 .\"O The owner (user ID) of the file is set to the effective user ID
356 .\"O of the process.
357 .\"O The group ownership (group ID) is set either to
358 .\"O the effective group ID of the process or to the group ID of the
359 .\"O parent directory (depending on file system type and mount options,
360 .\"O and the mode of the parent directory, see the mount options
361 .\"O .I bsdgroups
362 .\"O and
363 .\"O .I sysvgroups
364 .\"O described in
365 .\"O .BR mount (8)).
366 .\"O .\" As at 2.6.25, bsdgroups is supported by ext2, ext3, ext4, and
367 .\"O .\" XFS (since 2.6.14).
368 ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô (¥æ¡¼¥¶¡¼ ID) ¤Ï¡¢¥×¥í¥»¥¹¤Î¼Â¸ú¥æ¡¼¥¶¡¼ ID ¤ËÀßÄꤵ¤ì¤ë¡£
369 ¥°¥ë¡¼¥×½êÍ­¸¢ (¥°¥ë¡¼¥× ID) ¤Ï¡¢¥×¥í¥»¥¹¤Î¼Â¸ú¥°¥ë¡¼¥× ID
370 ¤Þ¤¿¤Ï¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î¥°¥ë¡¼¥× ID ¤ËÀßÄꤵ¤ì¤ë
371 (¤³¤ì¤Ï¡¢¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¥¿¥¤¥×¡¢¥Þ¥¦¥ó¥È¥ª¥×¥·¥ç¥ó¡¢
372 ¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î¥â¡¼¥É¤Ë°Í¸¤¹¤ë¡£
373 .BR mount (8)
374 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥Þ¥¦¥ó¥È¥ª¥×¥·¥ç¥ó
375 .I bsdgroups
376 ¤È
377 .I sysvgroups
378 ¤ò»²¾È)¡£
379 .\" 2.6.25 »þÅÀ¤Ç¤Ï¡¢bsdgroups ¤Ï ext2, ext3, ext4, XFS ¤Ç¥µ¥Ý¡¼¥È
380 .\" ¤µ¤ì¤Æ¤¤¤ë (2.6.14 °Ê¹ß)¡£
381 .RS
382 .PP
383 .\"O .I mode
384 .\"O specifies the permissions to use in case a new file is created.
385 .\"O This argument must be supplied when
386 .\"O .B O_CREAT
387 .\"O is specified in
388 .\"O .IR flags ;
389 .\"O if
390 .\"O .B O_CREAT
391 .\"O is not specified, then
392 .\"O .I mode
393 .\"O is ignored.
394 .\"O The effective permissions are modified by
395 .\"O the process's
396 .\"O .I umask
397 .\"O in the usual way: The permissions of the created file are
398 .\"O .IR "(mode\ &\ ~umask)" .
399 .I mode
400 ¤Ï¿·¤·¤¤¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë¾ì¹ç¤Ë»ÈÍѤ¹¤ë¥¢¥¯¥»¥¹µö²Ä (permission) ¤ò»ØÄꤹ¤ë¡£
401 .I flags
402 ¤Ë
403 .B O_CREAT
404 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
405 .I mode
406 ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
407 .B O_CREAT
408 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
409 .I mode
410 ¤Ï̵»ë¤µ¤ì¤ë¡£
411 Í­¸ú¤Ê¥¢¥¯¥»¥¹µö²Ä¤Ï¡¢ÉáÃʤÈƱ¤¸¤è¤¦¤Ë¥×¥í¥»¥¹¤Î
412 .I umask
413 ¤Ë¤è¤Ã¤Æ½¤Àµ¤µ¤ì¡¢ºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Îµö²Ä¤Ï
414 .I "(mode\ &\ ~umask)"
415 ¤È¤Ê¤ë¡£
416 .\"O Note that this mode only applies to future accesses of the
417 .\"O newly created file; the
418 .\"O .BR open ()
419 .\"O call that creates a read-only file may well return a read/write
420 .\"O file descriptor.
421 ¤³¤Î¥â¡¼¥É¤Ï¡¢¿·¤·¤¯ºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¤½¤ì°Ê¹ß¤Î¥¢¥¯¥»¥¹
422 ¤Ë¤Î¤ßŬÍѤµ¤ì¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
423 Æɤ߼è¤êÀìÍѤΥե¡¥¤¥ë¤òºîÀ®¤¹¤ë
424 .BR open ()
425 ¥³¡¼¥ë¤Ç¤¢¤Ã¤Æ¤â¡¢
426 Æɤ߽ñ¤­²Äǽ¤Ê¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¤³¤È¤¬¤¢¤ê¤¦¤ë¡£
427 .PP
428 .\"O The following symbolic constants are provided for
429 .\"O .IR mode :
430 .I mode
431 ¤Î¤¿¤á¤Ë°Ê²¼¤Î¥·¥ó¥Ü¥ëÄê¿ô¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë :
432 .TP 9
433 .B S_IRWXU
434 .\"O 00700 user (file owner) has read, write and execute permission
435 00700 ¥æ¡¼¥¶¡¼ (¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô) ¤ËÆɤ߹þ¤ß¡¢½ñ¤­¹þ¤ß¡¢
436 ¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
437 .TP
438 .B S_IRUSR
439 .\"O 00400 user has read permission
440 00400 ¥æ¡¼¥¶¡¼¤ËÆɤ߹þ¤ß¤Îµö²Ä¤¬¤¢¤ë¡£
441 .TP
442 .B S_IWUSR
443 .\"O 00200 user has write permission
444 00200 ¥æ¡¼¥¶¡¼¤Ë½ñ¤­¹þ¤ß¤Îµö²Ä¤¬¤¢¤ë¡£
445 .TP
446 .B S_IXUSR
447 .\"O 00100 user has execute permission
448 00100 ¥æ¡¼¥¶¡¼¤Ë¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
449 .TP
450 .B S_IRWXG
451 .\"O 00070 group has read, write and execute permission
452 00070 ¥°¥ë¡¼¥×¤ËÆɤ߹þ¤ß¡¢½ñ¤­¹þ¤ß¡¢¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
453 .TP
454 .B S_IRGRP
455 .\"O 00040 group has read permission
456 00040 ¥°¥ë¡¼¥×¤ËÆɤ߹þ¤ß¤Îµö²Ä¤¬¤¢¤ë¡£
457 .TP
458 .B S_IWGRP
459 .\"O 00020 group has write permission
460 00020 ¥°¥ë¡¼¥×¤Ë½ñ¤­¹þ¤ß¤Îµö²Ä¤¬¤¢¤ë¡£
461 .TP
462 .B S_IXGRP
463 .\"O 00010 group has execute permission
464 00010 ¥°¥ë¡¼¥×¤Ë¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
465 .TP
466 .B S_IRWXO
467 .\"O 00007 others have read, write and execute permission
468 00007 Â¾¿Í (others) ¤ËÆɤ߹þ¤ß¡¢½ñ¤­¹þ¤ß¡¢¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
469 .TP
470 .B S_IROTH
471 .\"O 00004 others have read permission
472 00004 Â¾¿Í¤ËÆɤ߹þ¤ß¤Îµö²Ä¤¬¤¢¤ë¡£
473 .TP
474 .B S_IWOTH
475 .\"O 00002 others have write permission
476 00002 Â¾¿Í¤Ë½ñ¤­¹þ¤ß¤Îµö²Ä¤¬¤¢¤ë¡£
477 .TP
478 .B S_IXOTH
479 .\"O 00001 others have execute permission
480 00001 Â¾¿Í¤Ë¼Â¹Ô¤Îµö²Ä¤¬¤¢¤ë¡£
481 .RE
482 .TP
483 .\"O .BR O_DIRECT " (Since Linux 2.4.10)"
484 .BR O_DIRECT " (Linux 2.4.10 °Ê¹ß)"
485 .\"O Try to minimize cache effects of the I/O to and from this file.
486 .\"O In general this will degrade performance, but it is useful in
487 .\"O special situations, such as when applications do their own caching.
488 .\"O File I/O is done directly to/from user space buffers.
489 ¤³¤Î¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë I/O ¤Î¥­¥ã¥Ã¥·¥å¤Î¸ú²Ì¤òºÇ¾®²½¤·¤è¤¦¤È¤¹¤ë¡£
490 ¤³¤Î¥Õ¥é¥°¤ò»È¤¦¤È¡¢°ìÈÌŪ¤ËÀ­Ç½¤¬Äã²¼¤¹¤ë¡£
491 ¤·¤«¤·¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Æȼ«¤Ë¥­¥ã¥Ã¥·¥ó¥°¤ò¹Ô¤Ã¤Æ¤¤¤ë¤è¤¦¤Ê
492 ÆÃÊ̤ʾì¹ç¤Ë¤ÏÌò¤ËΩ¤Ä¡£
493 ¥Õ¥¡¥¤¥ë¤Î I/O ¤Ï¥æ¡¼¥¶¡¼¶õ´Ö¥Ð¥Ã¥Õ¥¡¤ËÂФ·¤ÆľÀܹԤï¤ì¤ë¡£
494 .\"O The
495 .\"O .B O_DIRECT
496 .\"O flag on its own makes at an effort to transfer data synchronously,
497 .\"O but does not give the guarantees of the
498 .\"O .B O_SYNC
499 .\"O that data and necessary metadata are transferred.
500 .B O_DIRECT
501 ¥Õ¥é¥°¼«¿È¤Ï¥Ç¡¼¥¿¤òƱ´ü¤ÇžÁ÷¤·¤è¤¦¤È¤Ï¤¹¤ë¤¬¡¢
502 .B O_SYNC
503 ¤Î¤è¤¦¤Ë¥Ç¡¼¥¿¤ÈɬÍפʥ᥿¥Ç¡¼¥¿¤ÎžÁ÷¤¬Êݾڤµ¤ì¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
504 .\"O To guarantee synchronous I/O the
505 .\"O .B O_SYNC
506 .\"O must be used in addition to
507 .\"O .BR O_DIRECT .
508 Ʊ´ü I/O ¤òÊݾڤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
509 .B O_DIRECT
510 ¤Ë²Ã¤¨¤Æ
511 .B O_SYNC
512 ¤ò»ÈÍѤ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
513 .\"O See
514 .\"O .B NOTES
515 .\"O below for further discussion.
516 ¡ÖÃí°Õ¡×¤ÎÀá (²¼µ­) ¤ÎµÄÏÀ¤â»²¾È¡£
517 .sp
518 .\"O A semantically similar (but deprecated) interface for block devices
519 .\"O is described in
520 .\"O .BR raw (8).
521 ¥Ö¥í¥Ã¥¯¥Ç¥Ð¥¤¥¹¤ËÂФ¹¤ë»÷Ä̤ä¿°ÕÌ£¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤¬
522 .BR raw (8)
523 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë (⤷¡¢¤³¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ÏÈó¿ä¾©¤Ç¤¢¤ë)¡£
524 .TP
525 .B O_DIRECTORY
526 .\"O If \fIpathname\fP is not a directory, cause the open to fail.
527 .\"O .\" But see the following and its replies:
528 .\"O .\" http://marc.theaimsgroup.com/?t=112748702800001&r=1&w=2
529 .\"O .\" [PATCH] open: O_DIRECTORY and O_CREAT together should fail
530 .\"O .\" O_DIRECTORY | O_CREAT causes O_DIRECTORY to be ignored.
531 .\"O This flag is Linux-specific, and was added in kernel version 2.1.126, to
532 .\"O avoid denial-of-service problems if
533 .\"O .BR opendir (3)
534 .\"O is called on a
535 .\"O FIFO or tape device, but should not be used outside of the
536 .\"O implementation of
537 .\"O .BR opendir (3).
538 \fIpathname\fP ¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤±¤ì¤Ð¥ª¡¼¥×¥ó¤Ï¼ºÇÔ¤¹¤ë¡£
539 .\" °Ê²¼¤Îµ­»ö¤È¤½¤Î¥ê¥×¥é¥¤¤ò»²¾È¤Î¤³¤È¡£
540 .\" http://marc.theaimsgroup.com/?t=112748702800001&r=1&w=2
541 .\" [PATCH] open: O_DIRECTORY and O_CREAT together should fail
542 .\" O_DIRECTORY | O_CREAT ¤ò»ØÄꤹ¤ë¤È O_DIRECTORY ¤¬Ìµ»ë¤µ¤ì¤Æ¤·¤Þ¤¦¡£
543 ¤³¤Î¥Õ¥é¥°¤Ï Linux ÆÃÍ­¤Ç¤¢¤ê¡¢
544 .BR opendir (3)
545 ¤¬ FIFO ¤ä¥Æ¡¼¥×¥Ç¥Ð¥¤¥¹¤ËÂФ·¤Æ¥³¡¼¥ë¤µ¤ì¤¿¾ì¹ç¤Î
546 ¥µ¡¼¥Ó¥¹ÉÔǽ (denial-of-service) ¹¶·â¤òÈò¤±¤ë¤¿¤á¤Ë
547 ¥«¡¼¥Í¥ë 2.1.126 ¤ÇÄɲ䵤줿¡£
548 ¤·¤«¤·¤³¤ì¤Ï
549 .BR opendir (3)
550 ¤Î¼ÂÁõ°Ê³°¤Ç¤Ï»ÈÍѤ¹¤ë¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£
551 .TP
552 .B O_EXCL
553 .\"O Ensure that this call creates the file:
554 .\"O if this flag is specified in conjunction with
555 .\"O .BR O_CREAT ,
556 .\"O and
557 .\"O .I pathname
558 .\"O already exists, then
559 .\"O .BR open ()
560 .\"O will fail.
561 .\"O The behavior of
562 .\"O .B O_EXCL
563 .\"O is undefined if
564 .\"O .B O_CREAT
565 .\"O is not specified.
566 ¤³¤Î¸Æ¤Ó½Ð¤·¤Ç¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤ë¤³¤È¤òÊݾڤ¹¤ë¡£
567 ¤³¤Î¥Õ¥é¥°¤¬
568 .B O_CREAT
569 ¤È°ì½ï¤Ë»ØÄꤵ¤ì¡¢
570 .I pathname
571 ¤Î¥Õ¥¡¥¤¥ë¤¬´û¤Ë¸ºß¤·¤¿¾ì¹ç¡¢
572 .BR open ()
573 ¤Ï¼ºÇÔ¤¹¤ë¡£
574 .B O_CREAT
575 ¤¬»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Î
576 .B O_EXCL
577 ¤ÎÆ°ºî¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
578
579 .\"O When these two flags are specified, symbolic links are not followed:
580 .\"O .\" POSIX.1-2001 explicitly requires this behavior.
581 .\"O if
582 .\"O .I pathname
583 .\"O is a symbolic link, then
584 .\"O .BR open ()
585 .\"O fails regardless of where the symbolic link points to.
586 ¤³¤ì¤éÆó¤Ä¤Î¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤¿ºÝ¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ïé¤é¤ì¤Ê¤¤¡£
587 .\" POSIX.1-2001 ¤Ç¤ÏÌÀ¼¨Åª¤Ë¤³¤ÎÆ°ºî¤òÍ׵ᤷ¤Æ¤¤¤ë¡£
588 .I pathname
589 ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¡¢
590 ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤¬¤É¤³¤ò»Ø¤·¤Æ¤¤¤ë¤«¤Ë´Ø¤ï¤é¤º
591 .BR open ()
592 ¤Ï¼ºÇÔ¤¹¤ë¡£
593
594 .\"O .B O_EXCL
595 .\"O is only supported on NFS when using NFSv3 or later on kernel 2.6 or later.
596 .B O_EXCL
597 ¤Ï¡¢Linux 2.6 °Ê¹ß¤Ç NFSv3 °Ê¹ß¤ò»È¤Ã¤Æ¤¤¤ë NFS ¤Ç¤Î¤ß¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
598 .\"O In environments where NFS
599 .\"O .B O_EXCL
600 .\"O support is not provided, programs that rely on it
601 .\"O for performing locking tasks will contain a race condition.
602 .\"O Portable programs that want to perform atomic file locking using a lockfile,
603 .\"O and need to avoid reliance on NFS support for
604 .\"O .BR O_EXCL ,
605 .\"O can create a unique file on
606 .\"O the same file system (e.g., incorporating hostname and PID), and use
607 .\"O .BR link (2)
608 .\"O to make a link to the lockfile.
609 NFS ¤Î
610 .B O_EXCL
611 ¥µ¥Ý¡¼¥È¤¬Ä󶡤µ¤ì¤Æ¤¤¤Ê¤¤´Ä¶­¤Ç¤Ï¡¢¤³¤Î¥Õ¥é¥°¤ËÍê¤Ã¤Æ
612 ¥í¥Ã¥¯½èÍý¤ò¼Â¹Ô¤¹¤ë¥×¥í¥°¥é¥à¤Ï¶¥¹ç¾õÂÖ (race condition) ¤Ë½Ð²ñ¤¦
613 ²ÄǽÀ­¤¬¤¢¤ë¡£
614 ¥í¥Ã¥¯¥Õ¥¡¥¤¥ë¤ò»ÈÍѤ·¤ÆÉÔ²Äʬ (atomic) ¤Ê¥Õ¥¡¥¤¥ë¥í¥Ã¥¯¤ò¼Â¸½¤·¡¢
615 NFS ¤¬
616 .B O_EXCL
617 ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤«¤Ë°Í¸¤·¤Ê¤¤¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¡¢
618 °Ü¿¢À­¤Î¤¢¤ëÊýË¡¤Ï¡¢Æ±¤¸¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¾å¤Ë¾¤È̾Á°¤Î½Å¤Ê¤é¤Ê¤¤
619 ¥Õ¥¡¥¤¥ë (Î㤨¤Ð¥Û¥¹¥È̾¤È PID ¤òÁȤ߹ç¤ï¤»¤¿Ì¾Á°) ¤òºîÀ®¤·¡¢
620 .BR link (2)
621 ¤ò»ÈÍѤ·¤Æ¤½¤Î¥í¥Ã¥¯¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯¤òºîÀ®¤¹¤ë¤³¤È¤Ç¤¢¤ë¡£
622 .\"O If
623 .\"O .BR link (2)
624 .\"O returns 0, the lock is successful.
625 .\"O Otherwise, use
626 .\"O .BR stat (2)
627 .\"O on the unique file to check if its link count has increased to 2,
628 .\"O in which case the lock is also successful.
629 .BR link (2)
630 ¥³¡¼¥ë¤ÎÊÖ¤êÃͤ¬ 0 ¤Ê¤é¤Ð¥í¥Ã¥¯¤ËÀ®¸ù¤·¤Æ¤¤¤ë¡£
631 ¤¢¤ë¤¤¤Ï¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤Ë
632 .BR stat (2)
633 ¤ò»ÈÍѤ·¤Æ¥ê¥ó¥¯¿ô (link count) ¤¬ 2 ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£
634 ¤½¤¦¤Ê¤Ã¤Æ¤¤¤ì¤Ð¡¢Æ±¤¸¤¯¥í¥Ã¥¯¤ËÀ®¸ù¤·¤Æ¤¤¤ë¤È¤¤¤¦¤³¤È¤Ç¤¢¤ë¡£
635 .TP
636 .B O_LARGEFILE
637 (LFS)
638 .\"O Allow files whose sizes cannot be represented in an
639 .\"O .I off_t
640 .\"O (but can be represented in an
641 .\"O .IR off64_t )
642 .\"O to be opened.
643 .\"O The
644 .\"O .B _LARGEFILE64_SOURCE
645 .\"O macro must be defined in order to obtain this definition.
646 .\"O Setting the
647 .\"O .B _FILE_OFFSET_BITS
648 .\"O feature test macro to 64 (rather than using
649 .\"O .BR O_LARGEFILE )
650 .\"O is the preferred method of obtaining
651 .\"O method of accessing large files on 32-bit systems (see
652 .\"O .BR feature_test_macros (7)).
653 .I off_t
654 ¤Ç¤Ï¥µ¥¤¥º¤òɽ¤»¤Ê¤¤ (¤À¤À¤·
655 .I off64_t
656 ¤Ç¤Ï¥µ¥¤¥º¤òɽ¤»¤ë) ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó²Äǽ¤Ë¤¹¤ë¡£
657 ¤³¤ÎÄêµÁ¤òÍ­¸ú¤Ë¤¹¤ë¤¿¤á¤Ë¤Ï¡¢
658 .B _LARGEFILE64_SOURCE
659 ¥Þ¥¯¥í¤òÄêµÁ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
660 32¥Ó¥Ã¥È¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤ÆÂ礭¤Ê¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤¹¤ëÊýË¡¤òÆÀ¤¿¤¤¾ì¹ç¡¢
661 .RB ( O_LARGEFILE
662 ¤ò»È¤¦¤è¤ê¤â)
663 .B _FILE_OFFSET_BITS
664 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤ò¥»¥Ã¥È¤¹¤ëÊý¤¬Ë¾¤Þ¤·¤¤ÊýË¡¤Ç¤¢¤ë
665 .RB ( feature_test_macros (7)
666 ¤ò»²¾È)¡£
667 .TP
668 .\"O .BR O_NOATIME " (Since Linux 2.6.8)"
669 .BR O_NOATIME " (Linux 2.6.8 °Ê¹ß)"
670 .\"O Do not update the file last access time (st_atime in the inode)
671 .\"O when the file is
672 .\"O .BR read (2).
673 ¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
674 .BR read (2)
675 ¤¬¼Â¹Ô¤µ¤ì¤¿¤È¤­¤Ë¡¢ºÇ½ª¥¢¥¯¥»¥¹»þ¹ï (inode ¤Î st_atime) ¤ò¹¹¿·¤·¤Ê¤¤¡£
676 .\"O This flag is intended for use by indexing or backup programs,
677 .\"O where its use can significantly reduce the amount of disk activity.
678 ¤³¤Î¥Õ¥é¥°¤Ï¥¤¥ó¥Ç¥Ã¥¯¥¹ºîÀ®¤ä¥Ð¥Ã¥¯¥¢¥Ã¥×¥×¥í¥°¥é¥à¤Ç»È¤¦¤³¤È¤ò°Õ¿Þ¤·¤Æ¤¤¤ë¡£
679 ¤³¤ì¤ò»È¤¦¤È¥Ç¥£¥¹¥¯¤ËÂФ¹¤ëÁàºî¤òÂçÉý¤Ë¸º¤é¤¹¤³¤È¤¬¤Ç¤­¤ë¡£
680 .\"O This flag may not be effective on all file systems.
681 .\"O One example is NFS, where the server maintains the access time.
682 ¤³¤Î¥Õ¥é¥°¤ÏÁ´¤Æ¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ËÂФ·¤ÆÍ­¸ú¤Ç¤¢¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
683 ¤½¤Î°ìÎ㤬 NFS ¤Ç¤¢¤ê¡¢¥µ¡¼¥Ð¤¬¥¢¥¯¥»¥¹»þ¹ï¤ò´ÉÍý¤·¤Æ¤¤¤ë¡£
684 .\" The O_NOATIME flag also affects the treatment of st_atime
685 .\" by mmap() and readdir(2), MTK, Dec 04.
686 .TP
687 .B O_NOCTTY
688 .\"O If
689 .\"O .I pathname
690 .\"O refers to a terminal device \(em see
691 .\"O .BR tty (4)
692 .\"O \(em it will not become the process's controlling terminal even if the
693 .\"O process does not have one.
694 .I pathname
695 ¤¬Ã¼Ëö (terminal) ¥Ç¥Ð¥¤¥¹
696 \(em
697 .BR tty (4)
698 »²¾È
699 \(em
700 ¤ò»Ø¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¡¢¤¿¤È¤¨¤½¤Î¥×¥í¥»¥¹¤¬À©¸æüËö¤ò»ý¤Ã¤Æ¤¤¤Ê¤¯¤Æ¤â¡¢
701 ¥ª¡¼¥×¥ó¤·¤¿¥Õ¥¡¥¤¥ë¤ÏÀ©¸æüËö¤Ë¤Ï¤Ê¤é¤Ê¤¤¡£
702 .TP
703 .B O_NOFOLLOW
704 .\"O If \fIpathname\fP is a symbolic link, then the open fails.
705 .\"O This is a FreeBSD extension, which was added to Linux in version 2.1.126.
706 .\"O Symbolic links in earlier components of the pathname will still be
707 .\"O followed.
708 .\"O .\" The headers from glibc 2.0.100 and later include a
709 .\"O .\" definition of this flag; \fIkernels before 2.1.126 will ignore it if
710 .\"O .\" used\fP.
711 \fIpathname\fP ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤À¤Ã¤¿¾ì¹ç¡¢¥ª¡¼¥×¥ó¤Ï¼ºÇÔ¤¹¤ë¡£
712 ¤³¤ì¤Ï FreeBSD ¤Î³ÈÄ¥¤Ç¡¢Linux ¤Ë¤Ï 2.1.126 ¤è¤êÄɲ䵤줿¡£
713 pathname ¤ÎÁ°¤Î¥³¥ó¥Ý¡¼¥Í¥ó¥È (earlier component;
714 ÌõÃð: ºÇ¸å¤Î¥Ç¥£¥ì¥¯¥È¥ê¥»¥Ñ¥ì¡¼¥¿¤è¤êÁ°¤ÎÉôʬ) ¤¬
715 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Ç¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢¤½¤ì¤¬»Ø¤¹À褬»²¾È¤µ¤ì¤ë¡£
716 .\" glibc 2.0.100 °Ê¹ß¤Î¥Ø¥Ã¥À¡¼¤Ë¤Ï¤³¤Î¥Õ¥é¥°¤ÎÄêµÁ¤¬¤¢¤ë¡£
717 .\" \fI2.1.126 °ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç»ÈÍѤ·¤¿¾ì¹ç¤Ë¤Ï̵»ë¤µ¤ì¤ë¡£\fP
718 .TP
719 .\"O .BR O_NONBLOCK " or " O_NDELAY
720 .BR O_NONBLOCK " ¤Þ¤¿¤Ï " O_NDELAY
721 .\"O When possible, the file is opened in nonblocking mode.
722 .\"O Neither the
723 .\"O .BR open ()
724 .\"O nor any subsequent operations on the file descriptor which is
725 .\"O returned will cause the calling process to wait.
726 .\"O For the handling of FIFOs (named pipes), see also
727 .\"O .BR fifo (7).
728 .\"O For a discussion of the effect of
729 .\"O .B O_NONBLOCK
730 .\"O in conjunction with mandatory file locks and with file leases, see
731 .\"O .BR fcntl (2).
732 ²Äǽ¤Ê¤é¤Ð¡¢¥Õ¥¡¥¤¥ë¤ÏÈóÄä»ß (nonblocking) ¥â¡¼¥É¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤ë¡£
733 .BR open ()
734 ¤â¡¢ÊÖ¤·¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ¹¤ë°Ê¸å¤Î¤¹¤Ù¤Æ¤ÎÁàºî¤â
735 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤òÂÔ¤¿¤»¤ë¤³¤È¤Ï¤Ê¤¤¡£
736 FIFO (¥Í¡¼¥à¥É¡¦¥Ñ¥¤¥×) ¤ò°·¤¦¾ì¹ç¤Ë¤Ï
737 .BR fifo (7)
738 ¤â»²¾È¤¹¤ë¤³¤È¡£
739 ¶¯À©¥Õ¥¡¥¤¥ë¥í¥Ã¥¯ (mandatory file lock) ¤ä¥Õ¥¡¥¤¥ë¥ê¡¼¥¹ (file lease)
740 ¤ÈÁȤ߹ç¤ï¤»¤¿¾ì¹ç¤Î¡¢
741 .B O_NONBLOCK
742 ¤Î¸ú²Ì¤Ë¤Ä¤¤¤Æ¤ÎµÄÏÀ¤Ï¡¢
743 .BR fcntl (2)
744 ¤ò»²¾È¤¹¤ë¤³¤È¡£
745 .TP
746 .B O_SYNC
747 .\"O The file is opened for synchronous I/O.
748 .\"O Any
749 .\"O .BR write (2)s
750 .\"O on the resulting file descriptor will block the calling process until
751 .\"O the data has been physically written to the underlying hardware.
752 .\"O .IR "But see NOTES below" .
753 ¥Õ¥¡¥¤¥ë¤ÏƱ´ü (synchronous) I/O ¥â¡¼¥É¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤ë¡£
754 .BR open ()
755 ¤¬ÊÖ¤·¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ
756 .BR write (2)
757 ¤ò¹Ô¤¦¤È¡¢É¬¤º¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤ò¥Ö¥í¥Ã¥¯¤·¡¢
758 ³ºÅö¥Ï¡¼¥É¥¦¥§¥¢¤ËʪÍýŪ¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¤Þ¤ÇÊÖ¤é¤Ê¤¤¡£
759 .I °Ê²¼¤Î¡ÖÃí°Õ¡×¤Î¾Ï¤â»²¾È¡£
760 .TP
761 .B O_TRUNC
762 .\"O If the file already exists and is a regular file and the open mode allows
763 .\"O writing (i.e., is
764 .\"O .B O_RDWR
765 .\"O or
766 .\"O .BR O_WRONLY )
767 .\"O it will be truncated to length 0.
768 .\"O If the file is a FIFO or terminal device file, the
769 .\"O .B O_TRUNC
770 .\"O flag is ignored.
771 .\"O Otherwise the effect of
772 .\"O .B O_TRUNC
773 .\"O is unspecified.
774 ¥Õ¥¡¥¤¥ë¤¬´û¤Ë¸ºß¤·¡¢Ä̾ï¥Õ¥¡¥¤¥ë¤Ç¤¢¤ê¡¢
775 ½ñ¤­¹þ¤ß²Ä¥â¡¼¥É¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë
776 (¤Ä¤Þ¤ê¡¢
777 .BR O_RDWR "¤Þ¤¿¤Ï" O_WRONLY
778 ¤Î) ¾ì¹ç¡¢Ä¹¤µ 0 ¤ËÀÚ¤êµÍ¤á (truncate) ¤é¤ì¤ë¡£
779 ¥Õ¥¡¥¤¥ë¤¬ FIFO ¤Þ¤¿¤ÏüËö¥Ç¥Ð¥¤¥¹¥Õ¥¡¥¤¥ë¤Î¾ì¹ç¡¢
780 .B O_TRUNC
781 ¥Õ¥é¥°¤Ï̵»ë¤µ¤ì¤ë¡£
782 ¤½¤ì°Ê³°¤Î¾ì¹ç¡¢
783 .B O_TRUNC
784 ¤Î¸ú²Ì¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
785 .PP
786 .\"O Some of these optional flags can be altered using
787 .\"O .BR fcntl (2)
788 .\"O after the file has been opened.
789 ¤³¤ì¤é¤ÎÁªÂò¥Õ¥é¥°¤Î¤¤¤¯¤Ä¤«¤Ï¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤·¤¿¸å¤Ç¤â
790 .BR fcntl (2)
791 ¤ò»ÈÍѤ·¤ÆÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
792
793 .\"O .BR creat ()
794 .\"O is equivalent to
795 .\"O .BR open ()
796 .\"O with
797 .\"O .I flags
798 .\"O equal to
799 .\"O .BR O_CREAT|O_WRONLY|O_TRUNC .
800 .BR creat ()
801 ¤Ï
802 .I flags
803 ¤Ë
804 .B O_CREAT|O_WRONLY|O_TRUNC
805 ¤ò»ØÄꤷ¤Æ
806 .BR open ()
807 ¤ò¹Ô¤¦¤Î¤ÈÅù²Á¤Ç¤¢¤ë¡£
808 .\"O .SH "RETURN VALUE"
809 .SH ÊÖ¤êÃÍ
810 .\"O .BR open ()
811 .\"O and
812 .\"O .BR creat ()
813 .\"O return the new file descriptor, or \-1 if an error occurred
814 .\"O (in which case,
815 .\"O .I errno
816 .\"O is set appropriately).
817 .BR open ()
818 ¤È
819 .BR creat ()
820 ¤Ï¿·¤·¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
821 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹
822 (¤½¤Î¾ì¹ç¤Ï
823 .I errno
824 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë)¡£
825 .\"O .SH ERRORS
826 .SH ¥¨¥é¡¼
827 .TP
828 .B EACCES
829 .\"O The requested access to the file is not allowed, or search permission
830 .\"O is denied for one of the directories in the path prefix of
831 .\"O .IR pathname ,
832 .\"O or the file did not exist yet and write access to the parent directory
833 .\"O is not allowed.
834 .\"O (See also
835 .\"O .BR path_resolution (7).)
836 ¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ëÍ׵ᤵ¤ì¤¿¥¢¥¯¥»¥¹¤¬µö¤µ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢
837 .I pathname
838 ¤Î¥Ç¥£¥ì¥¯¥È¥êÉôʬ¤Î²¿¤ì¤«¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë¸¡º÷µö²Ä¤¬¤Ê¤«¤Ã¤¿¡£
839 ¤Þ¤¿¤Ï¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤»¤º¡¢¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ø¤Î½ñ¤­¹þ¤ßµö²Ä¤¬¤Ê¤«¤Ã¤¿¡£
840 .RB ( path_resolution (7)
841 ¤â»²¾È¤¹¤ë¤³¤È¡£)
842 .TP
843 .B EEXIST
844 .\"O .I pathname
845 .\"O already exists and
846 .\"O .BR O_CREAT " and " O_EXCL
847 .\"O were used.
848 .I pathname
849 ¤Ï´û¤Ë¸ºß¤·¡¢
850 .BR O_CREAT " ¤È " O_EXCL
851 ¤¬»ÈÍѤµ¤ì¤¿¡£
852 .TP
853 .B EFAULT
854 .\"O .I pathname
855 .\"O points outside your accessible address space.
856 .I pathname
857 ¤Î»Ø¤¹Îΰ褬¥¢¥¯¥»¥¹²Äǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤Ë¤Ê¤¤¡£
858 .TP
859 .B EFBIG
860 .\"O See
861 .\"O .BR EOVERFLOW .
862 .B EOVERFLOW
863 »²¾È¡£
864 .TP
865 .B EINTR
866 .\"O While blocked waiting to complete an open of a slow device
867 .\"O (e.g., a FIFO; see
868 .\"O .BR fifo (7)),
869 .\"O the call was interrupted by a signal handler; see
870 .\"O .BR signal (7).
871 ÃÙ¤¤¥Ç¥Ð¥¤¥¹
872 (Î㤨¤Ð FIFO¡¢
873 .BR fifo (7)
874 »²¾È) ¤Î¥ª¡¼¥×¥ó¤¬´°Î»¤¹¤ë¤Î¤òÂԤäÆÄä»ß¤·¤Æ¤¤¤ë´Ö¤Ë
875 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤ê³ä¤ê¹þ¤Þ¤ì¤¿¡£
876 .BR signal (7)
877 »²¾È¡£
878 .TP
879 .B EISDIR
880 .\"O .I pathname
881 .\"O refers to a directory and the access requested involved writing
882 .\"O (that is,
883 .\"O .B O_WRONLY
884 .\"O or
885 .\"O .B O_RDWR
886 .\"O is set).
887 .I pathname
888 ¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤ò»²¾È¤·¤Æ¤ª¤ê¡¢½ñ¤­¹þ¤ßÍ׵᤬´Þ¤Þ¤ì¤Æ¤¤¤¿
889 (¤Ä¤Þ¤ê
890 .B O_WRONLY
891 ¤Þ¤¿¤Ï
892 .B O_RDWR
893 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë)¡£
894 .TP
895 .B ELOOP
896 .\"O Too many symbolic links were encountered in resolving
897 .\"O .IR pathname ,
898 .\"O or \fBO_NOFOLLOW\fP was specified but
899 .\"O .I pathname
900 .\"O was a symbolic link.
901 .I pathname
902 ¤ò²ò·è¤¹¤ëºÝ¤ËÁø¶ø¤·¤¿¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤ë¡£
903 ¤Þ¤¿¤Ï \fBO_NOFOLLOW\fP ¤¬»ØÄꤵ¤ì¤Æ¤ª¤ê¡¢
904 .I pathname
905 ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤À¤Ã¤¿¡£
906 .TP
907 .B EMFILE
908 .\"O The process already has the maximum number of files open.
909 ¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¿ô¤¬¤¹¤Ç¤ËºÇÂç¿ô¤Ë㤷¤Æ¤¤¤ë¡£
910 .TP
911 .B ENAMETOOLONG
912 .\"O .I pathname
913 .\"O was too long.
914 .I pathname
915 ¤¬Ä¹²á¤®¤ë¡£
916 .TP
917 .B ENFILE
918 .\"O The system limit on the total number of open files has been reached.
919 ¥ª¡¼¥×¥ó¤Ç¤­¤ë¥Õ¥¡¥¤¥ë¤Î¹ç·×¿ô¤¬¥·¥¹¥Æ¥àÀ©¸Â¤Ë㤷¤Æ¤¤¤ë¡£
920 .TP
921 .B ENODEV
922 .\"O .I pathname
923 .\"O refers to a device special file and no corresponding device exists.
924 .\"O (This is a Linux kernel bug; in this situation
925 .\"O .B ENXIO
926 .\"O must be returned.)
927 .I pathname
928 ¤¬¥Ç¥Ð¥¤¥¹¡¦¥¹¥Ú¥·¥ã¥ë¡¦¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤ª¤ê¡¢Âбþ¤¹¤ë¥Ç¥Ð¥¤¥¹¤¬Â¸ºß¤·¤Ê¤¤¡£
929 (¤³¤ì¤Ï Linux ¥«¡¼¥Í¥ë¤Î¥Ð¥°¤Ç¤¢¤ê¡¢¤³¤Î¾ì¹ç¤Ë¤Ï
930 .B ENXIO
931 ¤¬ÊÖ¤µ¤ì¤ë¤Ù¤­¤Ç¤¢¤ë)
932 .TP
933 .B ENOENT
934 .\"O .B O_CREAT
935 .\"O is not set and the named file does not exist.
936 .\"O Or, a directory component in
937 .\"O .I pathname
938 .\"O does not exist or is a dangling symbolic link.
939 .B O_CREAT
940 ¤¬ÀßÄꤵ¤ì¤Æ¤ª¤é¤º¡¢¤«¤Ä»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¡£
941 ¤Þ¤¿¤Ï¡¢
942 .I pathname
943 ¤Î¥Ç¥£¥ì¥¯¥È¥êÉôʬ¤¬Â¸ºß¤·¤Ê¤¤¤«²õ¤ì¤¿ (dangling) ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Ç¤¢¤ë¡£
944 .TP
945 .B ENOMEM
946 .\"O Insufficient kernel memory was available.
947 ¥«¡¼¥Í¥ë¤ËÍøÍѤǤ­¤ë¥á¥â¥ê¤¬ÉÔ­¤·¤Æ¤¤¤ë
948 .TP
949 .B ENOSPC
950 .\"O .I pathname
951 .\"O was to be created but the device containing
952 .\"O .I pathname
953 .\"O has no room for the new file.
954 .I pathname
955 ¤òºîÀ®¤¹¤ëɬÍפ¬¤¢¤ë¤¬¡¢
956 .I pathname
957 ¤ò´Þ¤ó¤Ç¤¤¤ë¥Ç¥Ð¥¤¥¹¤Ë¿·¤·¤¤¥Õ¥¡¥¤¥ë¤Î¤¿¤á¤Î¶õ¤­ÍÆÎ̤¬¤Ê¤¤¡£
958 .TP
959 .B ENOTDIR
960 .\"O A component used as a directory in
961 .\"O .I pathname
962 .\"O is not, in fact, a directory, or \fBO_DIRECTORY\fP was specified and
963 .\"O .I pathname
964 .\"O was not a directory.
965 .I pathname
966 ¤Ë´Þ¤Þ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥êÉôʬ¤Î¤É¤ì¤«¤¬¼ÂºÝ¤Ë¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
967 ¤Þ¤¿¤Ï \fBO_DIRECTORY\fP ¤¬»ØÄꤵ¤ì¤Æ¤ª¤ê¡¢
968 .I pathname
969 ¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
970 .TP
971 .B ENXIO
972 .\"O .BR O_NONBLOCK " | " O_WRONLY
973 .\"O is set, the named file is a FIFO and
974 .\"O no process has the file open for reading.
975 .\"O Or, the file is a device special file and no corresponding device exists.
976 .BR O_NONBLOCK " | " O_WRONLY
977 ¤¬ÀßÄꤵ¤ì¤Æ¤ª¤ê¡¢»ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤¬ FIFO ¤Ç
978 ¤½¤Î¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¤Î¤¿¤á¤Ë¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥×¥í¥»¥¹¤¬Â¸ºß¤·¤Ê¤¤¡£
979 ¤Þ¤¿¤Ï¡¢¥Õ¥¡¥¤¥ë¤¬¥Ç¥Ð¥¤¥¹¡¦¥¹¥Ú¥·¥ã¥ë¡¦¥Õ¥¡¥¤¥ë¤Ç
980 Âбþ¤¹¤ë¥Ç¥Ð¥¤¥¹¤¬Â¸ºß¤·¤Ê¤¤¡£
981 .TP
982 .B EOVERFLOW
983 .\"O .I pathname
984 .\"O refers to a regular file that is too large to be opened.
985 .\"O The usual scenario here is that an application compiled
986 .\"O on a 32-bit platform without
987 .\"O .I -D_FILE_OFFSET_BITS=64
988 .\"O tried to open a file whose size exceeds
989 .\"O .I (2<<31)-1
990 .\"O bits;
991 .\"O see also
992 .\"O .B O_LARGEFILE
993 .\"O above.
994 .\"O This is the error specified by POSIX.1-2001;
995 .\"O in kernels before 2.6.24, Linux gave the error
996 .\"O .B EFBIG
997 .\"O for this case.
998 .I pathname
999 ¤¬»²¾È¤·¤Æ¤¤¤ë¤Î¤¬¡¢Â礭²á¤®¤Æ¥ª¡¼¥×¥ó¤Ç¤­¤Ê¤¤Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
1000 Ä̾¤³¤Î¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤Ï¡¢32 ¥Ó¥Ã¥È¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¾å¤Ç
1001 .I -D_FILE_OFFSET_BITS=64
1002 ¤ò»ØÄꤻ¤º¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¡¢¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬
1003 .I (2<31)-1
1004 ¥Ó¥Ã¥È¤òĶ¤¨¤ë¥Õ¥¡¥¤¥ë¤ò³«¤³¤¦¤È¤·¤¿¾ì¹ç¤Ç¤¢¤ë¡£
1005 ¾åµ­¤Î
1006 .B O_LARGEFILE
1007 ¤â»²¾È¡£
1008 ¤³¤ì¤Ï POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¥¨¥é¡¼¤Ç¤¢¤ë¡£
1009 2.6.24 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢Linux ¤Ï¤³¤Î¾ì¹ç¤Ë¥¨¥é¡¼
1010 .B EFBIG
1011 ¤òÊÖ¤·¤Æ¤¤¤¿¡£
1012 .\" See http://bugzilla.kernel.org/show_bug.cgi?id=7253
1013 .\" "Open of a large file on 32-bit fails with EFBIG, should be EOVERFLOW"
1014 .\" Reported 2006-10-03
1015 .TP
1016 .B EPERM
1017 .\"O The
1018 .\"O .B O_NOATIME
1019 .\"O flag was specified, but the effective user ID of the caller
1020 .\"O .\" Strictly speaking, it's the file system UID... (MTK)
1021 .\"O did not match the owner of the file and the caller was not privileged
1022 .\"O .RB ( CAP_FOWNER ).
1023 .B O_NOATIME
1024 ¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¼Â¸ú¥æ¡¼¥¶¡¼ ID ¤¬
1025 .\" ¸·Ì©¤Ë¸À¤¨¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à UID...(MTK)
1026 ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤È°ìÃפ»¤º¡¢¤«¤Ä¸Æ¤Ó½Ð¤·¸µ¤ËÆø¢
1027 .RB ( CAP_FOWNER )
1028 ¤¬¤Ê¤¤¡£
1029 .TP
1030 .B EROFS
1031 .\"O .I pathname
1032 .\"O refers to a file on a read-only file system and write access was
1033 .\"O requested.
1034 .I pathname
1035 ¤¬Æɤ߹þ¤ßÀìÍѤΥե¡¥¤¥ë¥·¥¹¥Æ¥à¾å¤Î¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤ª¤ê¡¢
1036 ½ñ¤­¹þ¤ß¥¢¥¯¥»¥¹¤¬Í׵ᤵ¤ì¤¿¡£
1037 .TP
1038 .B ETXTBSY
1039 .\"O .I pathname
1040 .\"O refers to an executable image which is currently being executed and
1041 .\"O write access was requested.
1042 .I pathname
1043 ¤¬¸½ºß¼Â¹ÔÃæ¤Î¼Â¹Ô¥¤¥á¡¼¥¸¤ò»²¾È¤·¤Æ¤ª¤ê¡¢½ñ¤­¹þ¤ß¤¬Í׵ᤵ¤ì¤¿¡£
1044 .TP
1045 .B EWOULDBLOCK
1046 .\"O The
1047 .\"O .B O_NONBLOCK
1048 .\"O flag was specified, and an incompatible lease was held on the file
1049 .\"O (see
1050 .\"O .BR fcntl (2)).
1051 .B O_NONBLOCK
1052 ¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤Ë¤ÏÌ·½â¤¹¤ë¥ê¡¼¥¹¤¬ÀßÄꤵ¤ì¤Æ¤¤¤¿
1053 .RB ( fcntl (2)
1054 »²¾È)¡£
1055 .\"O .SH "CONFORMING TO"
1056 .SH ½àµò
1057 SVr4, 4.3BSD, POSIX.1-2001.
1058 .\"O The
1059 .\"O .BR O_DIRECTORY ,
1060 .\"O .BR O_NOATIME ,
1061 .\"O and
1062 .\"O .B O_NOFOLLOW
1063 .\"O flags are Linux-specific, and one may need to define
1064 .\"O .B _GNU_SOURCE
1065 .\"O to obtain their definitions.
1066 ¥Õ¥é¥°
1067 .BR O_DIRECTORY ,
1068 .BR O_NOATIME ,
1069 .B O_NOFOLLOW
1070 ¤Ï Linux ÆÃÍ­¤Î¤â¤Î¤Ç¤¢¤ê¡¢
1071 ¤³¤ì¤é¤Î¥Õ¥é¥°¤ÎÄêµÁ¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢
1072 .B _GNU_SOURCE
1073 ¤òÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1074
1075 .\"O The
1076 .\"O .BR O_CLOEXEC
1077 .\"O flag is not specified in POSIX.1-2001,
1078 .\"O but is specified in POSIX.1-2008.
1079 .BR O_CLOEXEC
1080 ¥Õ¥é¥°¤Ï POSIX.1-2001 ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
1081 POSIX.1-2008 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
1082
1083 .\"O .B O_DIRECT
1084 .\"O is not specified in POSIX; one has to define
1085 .\"O .B _GNU_SOURCE
1086 .\"O to get its definition.
1087 .B O_DIRECT
1088 ¤Ï POSIX ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
1089 .B O_DIRECT
1090 ¤ÎÄêµÁ¤òÆÀ¤ë¤Ë¤Ï
1091 .B _GNU_SOURCE
1092 ¤òÄêµÁ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1093 .\"O .SH NOTES
1094 .SH Ãí°Õ
1095 .\"O Under Linux, the
1096 .\"O .B O_NONBLOCK
1097 .\"O  flag indicates that one wants to open
1098 .\"O but does not necessarily have the intention to read or write.
1099 Linux ¤Ç¤Ï¡¢
1100 .B O_NONBLOCK
1101 ¥Õ¥é¥°¤Ï¡¢
1102 open ¤ò¼Â¹Ô¤·¤¿¤¤¤¬ read ¤Þ¤¿¤Ï write ¤ò¼Â¹Ô¤¹¤ë°Õ¿Þ¤Ï
1103 ɬ¤º¤·¤â¤Ê¤¤¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
1104 .\"O This is typically used to open devices in order to get a file descriptor
1105 .\"O for use with
1106 .\"O .BR ioctl (2).
1107 ¤³¤ì¤Ï
1108 .BR ioctl (2)
1109 ¤Î¤¿¤á¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¡¢
1110 ¥Ç¥Ð¥¤¥¹¤ò¥ª¡¼¥×¥ó¤¹¤ë¤È¤­¤Ë¤è¤¯ÍѤ¤¤é¤ì¤ë¡£
1111
1112 .\"O Unlike the other values that can be specified in
1113 .\"O .IR flags ,
1114 .\"O the
1115 .\"O .I "access mode"
1116 .\"O values
1117 .\"O .BR O_RDONLY ", " O_WRONLY ", and " O_RDWR ,
1118 .\"O do not specify individual bits.
1119 .\"O Rather, they define the low order two bits of
1120 .\"O .IR flags ,
1121 .\"O and are defined respectively as 0, 1, and 2.
1122 ¡Ö¥¢¥¯¥»¥¹¥â¡¼¥É¡×¤ÎÃÍ
1123 .BR O_RDONLY ", " O_WRONLY ", " O_RDWR
1124 ¤Ï¡¢
1125 .I flags
1126 ¤Ë»ØÄê¤Ç¤­¤ë¾¤ÎÃͤȰ㤤¡¢¸Ä¡¹¤Î¥Ó¥Ã¥È¤ò»ØÄꤹ¤ë¤â¤Î¤Ç¤Ï¤Ê¤¯¡¢
1127 ¤³¤ì¤é¤ÎÃͤÏ
1128 .I flags
1129 ¤Î²¼°Ì 2 ¥Ó¥Ã¥È¤òÄêµÁ¤¹¤ë¡£
1130 .BR O_RDONLY ", " O_WRONLY ", " O_RDWR
1131 ¤Ï¤½¤ì¤¾¤ì 0, 1, 2 ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
1132 .\"O In other words, the combination
1133 .\"O .B "O_RDONLY | O_WRONLY"
1134 .\"O is a logical error, and certainly does not have the same meaning as
1135 .\"O .BR O_RDWR .
1136 ¸À¤¤´¹¤¨¤ë¤È¡¢
1137 .B "O_RDONLY | O_WRONLY"
1138 ¤ÎÁȤ߹ç¤ï¤»¤ÏÏÀÍýŪ¤Ë´Ö°ã¤¤¤Ç¤¢¤ê¡¢³Î¤«¤Ë
1139 .B O_RDWR
1140 ¤ÈƱ¤¸°ÕÌ£¤Ç¤Ï¤Ê¤¤¡£
1141 .\"O Linux reserves the special, nonstandard access mode 3 (binary 11) in
1142 .\"O .I flags
1143 .\"O to mean:
1144 .\"O check for read and write permission on the file and return a descriptor
1145 .\"O that can't be used for reading or writing.
1146 .\"O This nonstandard access mode is used by some Linux drivers to return a
1147 .\"O descriptor that is only to be used for device-specific
1148 .\"O .BR ioctl (2)
1149 .\"O operations.
1150 Linux ¤Ç¤Ï¡¢ÆÃÊ̤ʡ¢Èóɸ½à¤Ê¥¢¥¯¥»¥¹¥â¡¼¥É¤È¤·¤Æ 3 (¥Ð¥¤¥Ê¥ê¤Ç¤Ï 11) ¤¬
1151 ͽÌ󤵤ì¤Æ¤ª¤ê
1152 .I flags
1153 ¤Ë»ØÄê¤Ç¤­¤ë¡£
1154 ¤³¤Î¥¢¥¯¥»¥¹¥â¡¼¥É¤ò»ØÄꤹ¤ë¤È¡¢¥Õ¥¡¥¤¥ë¤ÎÆɤ߽Ф·/½ñ¤­¹þ¤ßµö²Ä¤ò¥Á¥§¥Ã¥¯¤·¡¢
1155 Æɤ߽Ф·¤Ë¤â½ñ¤­¹þ¤ß¤Ë¤â»ÈÍѤǤ­¤Ê¤¤¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
1156 ¤³¤ÎÈóɸ½à¤Î¥¢¥¯¥»¥¹¥â¡¼¥É¤Ï¤¤¤¯¤Ä¤«¤Î Linux ¥É¥é¥¤¥Ð¤Ç»ÈÍѤµ¤ì¤Æ¤ª¤ê¡¢
1157 ¥Ç¥Ð¥¤¥¹¸ÇÍ­¤Î
1158 .BR ioctl (2)
1159 Áàºî¤Ë¤Î¤ß»ÈÍѤµ¤ì¤ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¤¿¤á¤Ë»È¤ï¤ì¤Æ¤¤¤ë¡£
1160 .\" See for example util-linux's disk-utils/setfdprm.c
1161 .\" For some background on access mode 3, see
1162 .\" http://thread.gmane.org/gmane.linux.kernel/653123
1163 .\" "[RFC] correct flags to f_mode conversion in __dentry_open"
1164 .\" LKML, 12 Mar 2008
1165 .LP
1166 .\"O The (undefined) effect of
1167 .\"O .B O_RDONLY | O_TRUNC
1168 .\"O varies among implementations.
1169 .\"O On many systems the file is actually truncated.
1170 .B O_RDONLY | O_TRUNC
1171 ¤Î±Æ¶Á¤Ï̤ÄêµÁ¤Ç¤¢¤ê¡¢¤½¤ÎÆ°ºî¤Ï¼ÂÁõ¤Ë¤è¤Ã¤Æ°Û¤Ê¤ë¡£
1172 ¿¤¯¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¥Õ¥¡¥¤¥ë¤Ï¼ÂºÝ¤ËÀÚ¤êµÍ¤á¤é¤ì¤ë¡£
1173 .\" Linux 2.0, 2.5: truncate
1174 .\" Solaris 5.7, 5.8: truncate
1175 .\" Irix 6.5: truncate
1176 .\" Tru64 5.1B: truncate
1177 .\" HP-UX 11.22: truncate
1178 .\" FreeBSD 4.7: truncate
1179 .PP
1180 .\"O There are many infelicities in the protocol underlying NFS, affecting
1181 .\"O amongst others
1182 .\"O .BR O_SYNC " and " O_NDELAY .
1183 NFS ¤ò¼Â¸½¤·¤Æ¤¤¤ë¥×¥í¥È¥³¥ë¤Ë¤Ï¿¤¯¤ÎÉÔÈ÷¤¬¤¢¤ê¡¢ÆäË
1184 .BR O_SYNC " ¤È " O_NDELAY
1185 ¤Ë±Æ¶Á¤¹¤ë¡£
1186
1187 .\"O POSIX provides for three different variants of synchronized I/O,
1188 .\"O corresponding to the flags
1189 .\"O .BR O_SYNC ,
1190 .\"O .BR O_DSYNC ,
1191 .\"O and
1192 .\"O .BR O_RSYNC .
1193 POSIX ¤Ç¤Ï¡¢3 ¼ïÎà¤ÎƱ´ü I/O ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢
1194 .BR O_SYNC ,
1195 .BR O_DSYNC ,
1196 .BR O_RSYNC
1197 ¥Õ¥é¥°¤¬¤³¤ì¤ËÂбþ¤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
1198 .\"O Currently (2.6.31), Linux only implements
1199 .\"O .BR O_SYNC ,
1200 .\"O but glibc maps
1201 .\"O .B O_DSYNC
1202 .\"O and
1203 .\"O .B O_RSYNC
1204 .\"O to the same numerical value as
1205 .\"O .BR O_SYNC
1206 º£¤Î¤È¤³¤í (¥«¡¼¥Í¥ë 2.6.31)¡¢
1207 Linux ¤Ç¤Ï
1208 .B O_SYNC
1209 ¤À¤±¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢
1210 glibc ¤Ï
1211 .B O_DSYNC
1212 ¤È
1213 .B O_RSYNC
1214 ¤Ë
1215 .B O_SYNC
1216 ¤ÈƱ¤¸¿ôÃͤò³ä¤êÅö¤Æ¤Æ¤¤¤ë¡£
1217 .\"O Most Linux filesystems don't actually implement the POSIX
1218 .\"O .B O_SYNC
1219 .\"O semantics, which require all metadata updates of a write
1220 .\"O to be on disk on returning to userspace, but only the
1221 .\"O .B O_DSYNC
1222 .\"O semantics, which require only actual file data and metadata necessary
1223 .\"O to retrieve it to be on disk by the time the system call returns.
1224 ¤Û¤È¤ó¤É¤Î Linux ¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ï¡¢¼ÂºÝ¤Ë¤Ï POSIX ¤Î
1225 .B O_SYNC
1226 ¤ÎÆ°ºî¤Ç¤Ï¤Ê¤¯
1227 .B O_DSYNC
1228 ¤ÎÆ°ºî¤À¤±¤ò¼ÂÁõ¤·¤Æ¤¤¤ë¡£
1229 POSIX ¤Î
1230 .B O_SYNC
1231 ¤Ç¤Ï¡¢
1232 .BR open ()
1233 ¤¬¥æ¡¼¥¶¶õ´Ö¤ËÊÖ¤ëºÝ¤Ë¡¢½ñ¤­¹þ¤ß¤Ë´Ø¤¹¤ëÁ´¤Æ¤Î¥á¥¿¥Ç¡¼¥¿¤Î
1234 ¹¹¿·¤¬¥Ç¥£¥¹¥¯¤Ë½ñ¤­¹þ¤Þ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
1235 °ìÊý¡¢
1236 .B O_DSYNC
1237 ¤Ç¤Ï¡¢
1238 .BR open ()
1239 ¤¬ÊÖ¤ë¤Þ¤Ç¤Ë¡¢¼ÂºÝ¤Î¥Õ¥¡¥¤¥ë¤Î¥Ç¡¼¥¿¤È¤½¤Î¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë
1240 ɬÍפʥ᥿¥Ç¡¼¥¿¤À¤±¤¬¥Ç¥£¥¹¥¯¤Ë½ñ¤­¹þ¤Þ¤ì¤Æ¤¤¤ì¤Ð¤è¤¤¡£
1241
1242 .\"O Note that
1243 .\"O .BR open ()
1244 .\"O can open device special files, but
1245 .\"O .BR creat ()
1246 .\"O cannot create them; use
1247 .\"O .BR mknod (2)
1248 .\"O instead.
1249 .BR open ()
1250 ¤Ï¥¹¥Ú¥·¥ã¥ë¡¦¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤¬¡¢
1251 .BR creat ()
1252 ¤Ç¥¹¥Ú¥·¥ã¥ë¡¦¥Õ¥¡¥¤¥ë¤òºîÀ®¤Ç¤­¤Ê¤¤ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
1253 Âå¤ï¤ê¤Ë
1254 .BR mknod (2)
1255 ¤ò»ÈÍѤ¹¤ë¡£
1256 .LP
1257 .\"O On NFS file systems with UID mapping enabled,
1258 .\"O .BR open ()
1259 .\"O may
1260 .\"O return a file descriptor but, for example,
1261 .\"O .BR read (2)
1262 .\"O requests are denied
1263 .\"O with \fBEACCES\fP.
1264 .\"O This is because the client performs
1265 .\"O .BR open ()
1266 .\"O by checking the
1267 .\"O permissions, but UID mapping is performed by the server upon
1268 .\"O read and write requests.
1269 UID ¥Þ¥Ã¥Ô¥ó¥°¤ò»ÈÍѤ·¤Æ¤¤¤ë NFS ¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
1270 .BR open ()
1271 ¤¬¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤·¤¿¾ì¹ç¤Ç¤â
1272 .BR read (2)
1273 ¤¬ \fBEACCES\fP ¤ÇµñÈݤµ¤ì¤ë¾ì¹ç¤¬¤¢¤ë¡£
1274 ¤³¤ì¤Ï¥¯¥é¥¤¥¢¥ó¥È¤¬¥¢¥¯¥»¥¹µö²Ä¤Î¥Á¥§¥Ã¥¯¤ò¹Ô¤Ã¤Æ
1275 .BR open ()
1276 ¤ò¼Â¹Ô¤¹¤ë¤¬¡¢Æɤ߹þ¤ß¤ä½ñ¤­¹þ¤ß¤ÎºÝ¤Ë¤Ï
1277 ¥µ¡¼¥Ð¡¼¤Ç UID ¥Þ¥Ã¥Ô¥ó¥°¤¬¹Ô¤ï¤ì¤ë¤¿¤á¤Ç¤¢¤ë¡£
1278
1279 .\"O If the file is newly created, its
1280 .\"O .IR st_atime ,
1281 .\"O .IR st_ctime ,
1282 .\"O .I st_mtime
1283 .\"O fields
1284 .\"O (respectively, time of last access, time of last status change, and
1285 .\"O time of last modification; see
1286 .\"O .BR stat (2))
1287 .\"O are set
1288 .\"O to the current time, and so are the
1289 .\"O .I st_ctime
1290 .\"O and
1291 .\"O .I st_mtime
1292 .\"O fields of the
1293 .\"O parent directory.
1294 .\"O Otherwise, if the file is modified because of the
1295 .\"O .B O_TRUNC
1296 .\"O flag, its st_ctime and st_mtime fields are set to the current time.
1297 ¥Õ¥¡¥¤¥ë¤¬¿·¤·¤¯ºîÀ®¤µ¤ì¤ë¤È¡¢
1298 ¥Õ¥¡¥¤¥ë¤Î
1299 .IR st_atime ,
1300 .IR st_ctime ,
1301 .I st_mtime
1302 ¥Õ¥£¡¼¥ë¥É
1303 (¤½¤ì¤¾¤ìºÇ½ª¥¢¥¯¥»¥¹»þ¹ï¡¢ºÇ½ª¾õÂÖÊѹ¹»þ¹ï¡¢ºÇ½ª½¤Àµ»þ¹ï¤Ç¤¢¤ë¡£
1304 .BR stat (2)
1305 »²¾È) ¤¬¸½ºß»þ¹ï¤ËÀßÄꤵ¤ì¤ë¡£
1306 ¤µ¤é¤Ë¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î
1307 .I st_ctime
1308 ¤È
1309 .I st_mtime
1310 ¤â¸½ºß»þ¹ï¤ËÀßÄꤵ¤ì¤ë¡£
1311 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ç¡¢O_TRUNC ¥Õ¥é¥°¤Ç¥Õ¥¡¥¤¥ë¤¬½¤Àµ¤µ¤ì¤¿¤È¤­¤Ï¡¢
1312 ¥Õ¥¡¥¤¥ë¤Î
1313 .I st_ctime
1314 ¤È
1315 .I st_mtime
1316 ¥Õ¥£¡¼¥ë¥É¤¬¸½ºß»þ¹ï¤ËÀßÄꤵ¤ì¤ë¡£
1317 .SS O_DIRECT
1318 .LP
1319 .\"O The
1320 .\"O .B O_DIRECT
1321 .\"O flag may impose alignment restrictions on the length and address
1322 .\"O of userspace buffers and the file offset of I/Os.
1323 .\"O In Linux alignment
1324 .\"O restrictions vary by file system and kernel version and might be
1325 .\"O absent entirely.
1326 .\"O However there is currently no file system\-independent
1327 .\"O interface for an application to discover these restrictions for a given
1328 .\"O file or file system.
1329 .\"O Some file systems provide their own interfaces
1330 .\"O for doing so, for example the
1331 .\"O .B XFS_IOC_DIOINFO
1332 .\"O operation in
1333 .\"O .BR xfsctl (3).
1334 .B O_DIRECT
1335 ¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥æ¡¼¥¶¶õ´Ö¥Ð¥Ã¥Õ¥¡¤ÎŤµ¤ä¥¢¥É¥ì¥¹¡¢
1336 I/O ¤Î¥Õ¥¡¥¤¥ë¥ª¥Õ¥»¥Ã¥È¤Ë´Ø¤·¤Æ¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤¬²Ý¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
1337 Linux ¤Ç¤Ï¡¢¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ä¥«¡¼¥Í¥ë¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë
1338 ¤è¤Ã¤Æ°Û¤Ê¤ê¡¢Á´¤¯À©¸Â¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤â¤¢¤ë¡£
1339 ¤·¤«¤·¤Ê¤¬¤é¡¢¸½ºß¤Î¤È¤³¤í¡¢»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤ä¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ËÂФ·¤Æ
1340 ¤³¤¦¤·¤¿À©¸Â¤¬¤¢¤ë¤«¤ò¸«¤Ä¤±¤ë¤¿¤á¤Î¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¸þ¤±¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç
1341 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àÈó°Í¸¤Î¤â¤Î¤Ï¸ºß¤·¤Ê¤¤¡£
1342 ¤¤¤¯¤Ä¤«¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢À©¸Â¤ò³Îǧ¤¹¤ë¤¿¤á¤ÎÆȼ«¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤¬
1343 Ä󶡤µ¤ì¤Æ¤¤¤ë¡£Î㤨¤Ð¡¢
1344 .BR xfsctl (3)
1345 ¤Î
1346 .B XFS_IOC_DIOINFO
1347 Ì¿Îá¤Ç¤¢¤ë¡£
1348 .LP
1349 .\"O Under Linux 2.4, transfer sizes, and the alignment of the user buffer
1350 .\"O and the file offset must all be multiples of the logical block size
1351 .\"O of the file system.
1352 .\"O Under Linux 2.6, alignment to 512-byte boundaries
1353 .\"O suffices.
1354 Linux 2.4 ¤Ç¤Ï¡¢Å¾Á÷¥µ¥¤¥º¡¢
1355 ¥æ¡¼¥¶¡¼¥Ð¥Ã¥Õ¥¡¤Î¥¢¥é¥¤¥ó¥á¥ó¥È¡¢¥Õ¥¡¥¤¥ë¥ª¥Õ¥»¥Ã¥È¤Ï¡¢
1356 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ÎÏÀÍý¥Ö¥í¥Ã¥¯¥µ¥¤¥º¤ÎÇÜ¿ô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1357 Linux 2.6 ¤Ç¤Ï¡¢512 ¥Ð¥¤¥È¤´¤È¤Î¶­³¦¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ì¤Ð½¼Ê¬¤Ç¤¢¤ë¡£
1358 .LP
1359 .\"O The
1360 .\"O .B O_DIRECT
1361 .\"O flag was introduced in SGI IRIX, where it has alignment
1362 .\"O restrictions similar to those of Linux 2.4.
1363 .\"O IRIX has also a
1364 .\"O .BR fcntl (2)
1365 .\"O call to query appropriate alignments, and sizes.
1366 .\"O FreeBSD 4.x introduced
1367 .\"O a flag of the same name, but without alignment restrictions.
1368 .B O_DIRECT
1369 ¥Õ¥é¥°¤Ï  SGI IRIX ¤ÇƳÆþ¤µ¤ì¤¿¡£SGI IRIX ¤Ë¤â Linux 2.4 ¤ÈƱÍͤÎ
1370 (¥æ¡¼¥¶¡¼¥Ð¥Ã¥Õ¥¡¤Î) ¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤¬¤¢¤ë¡£
1371 ¤Þ¤¿¡¢IRIX ¤Ë¤ÏŬÀÚ¤ÊÇÛÃ֤ȥµ¥¤¥º¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Î
1372 .BR fcntl (2)
1373 ¥³¡¼¥ë¤¬¤¢¤ë¡£
1374 FreeBSD 4.x ¤âƱ¤¸Ì¾Á°¤Î¥Õ¥é¥°¤òƳÆþ¤·¤¿¤¬¡¢¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤Ï¤Ê¤¤¡£
1375 .LP
1376 .\"O .B O_DIRECT
1377 .\"O support was added under Linux in kernel version 2.4.10.
1378 .\"O Older Linux kernels simply ignore this flag.
1379 .\"O Some file systems may not implement the flag and
1380 .\"O .BR open ()
1381 .\"O will fail with
1382 .\"O .B EINVAL
1383 .\"O if it is used.
1384 .B O_DIRECT
1385 ¤¬ Linux ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤¿¤Î¤Ï¡¢¥«¡¼¥Í¥ë¥Ð¡¼¥¸¥ç¥ó 2.4.10 ¤Ç¤¢¤ë¡£
1386 ¸Å¤¤ Linux ¥«¡¼¥Í¥ë¤Ï¡¢¤³¤Î¥Õ¥é¥°¤òñ¤Ë̵»ë¤¹¤ë¡£
1387 .B O_DIRECT
1388 ¥Õ¥é¥°¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤â¤¢¤ê¡¢¤½¤Î¾ì¹ç¤Ï¡¢
1389 .B O_DIRECT
1390 ¤ò»ÈÍѤ¹¤ë¤È
1391 .BR open ()
1392 ¤Ï
1393 .B EINVAL
1394 ¤Ç¼ºÇÔ¤¹¤ë¡£
1395 .LP
1396 .\"O Applications should avoid mixing
1397 .\"O .B O_DIRECT
1398 .\"O and normal I/O to the same file,
1399 .\"O and especially to overlapping byte regions in the same file.
1400 .\"O Even when the file system correctly handles the coherency issues in
1401 .\"O this situation, overall I/O throughput is likely to be slower than
1402 .\"O using either mode alone.
1403 .\"O Likewise, applications should avoid mixing
1404 .\"O .BR mmap (2)
1405 .\"O of files with direct I/O to the same files.
1406 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢Æ±¤¸¥Õ¥¡¥¤¥ë¡¢
1407 ÆäËƱ¤¸¥Õ¥¡¥¤¥ë¤Î½ÅÊ£¤¹¤ë¥Ð¥¤¥ÈÎΰè¤ËÂФ·¤Æ¡¢
1408 .B O_DIRECT
1409 ¤ÈÄ̾ï¤Î I/O ¤òº®¤¼¤Æ»È¤¦¤Î¤ÏÈò¤±¤ë¤Ù¤­¤Ç¤¢¤ë¡£
1410 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ë¤ª¤¤¤Æ°ì´ÓÀ­¤ÎÌäÂê¤òÀµ¤·¤¯
1411 °·¤¦¤³¤È¤¬¤Ç¤­¤ë¾ì¹ç¤Ç¤¢¤Ã¤Æ¤â¡¢Á´ÂΤΠI/O ¥¹¥ë¡¼¥×¥Ã¥È¤Ï
1412 ¤É¤Á¤é¤«°ìÊý¤ò»ÈÍѤ¹¤ë¤È¤­¤ÈÈæ¤Ù¤ÆÄ㮤ˤʤë¤Ç¤¢¤í¤¦¡£
1413 ƱÍͤˡ¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢Æ±¤¸¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
1414 .BR mmap (2)
1415 ¤ÈľÀÜ I/O
1416 .RB ( O_DIRECT )
1417 ¤òº®¤¼¤Æ»È¤¦¤Î¤âÈò¤±¤ë¤Ù¤­¤Ç¤¢¤ë¡£
1418 .LP
1419 .\"O The behaviour of
1420 .\"O .B O_DIRECT
1421 .\"O with NFS will differ from local file systems.
1422 .\"O Older kernels, or
1423 .\"O kernels configured in certain ways, may not support this combination.
1424 .\"O The NFS protocol does not support passing the flag to the server, so
1425 .\"O .B O_DIRECT
1426 .\"O I/O will only bypass the page cache on the client; the server may
1427 .\"O still cache the I/O.
1428 NFS ¤Ç
1429 .B O_DIRECT
1430 ¤ò»È¤Ã¤¿¾ì¹ç¤ÎÆ°ºî¤Ï¥í¡¼¥«¥ë¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î¾ì¹ç¤È°ã¤¦¡£
1431 ¸Å¤¤¥«¡¼¥Í¥ë¤ä¡¢¤¢¤ë¼ï¤ÎÀßÄê¤Ç¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥«¡¼¥Í¥ë¤Ï¡¢
1432 .B O_DIRECT
1433 ¤È NFS ¤ÎÁȤ߹ç¤ï¤»¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¡£
1434 NFS ¥×¥í¥È¥³¥ë¼«ÂΤϥµ¡¼¥Ð¤Ë¥Õ¥é¥°¤òÅϤ¹µ¡Ç½¤Ï»ý¤Ã¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
1435 .B O_DIRECT
1436 I/O ¤Ï¥¯¥é¥¤¥¢¥ó¥È¾å¤Î¥Ú¡¼¥¸¥­¥ã¥Ã¥·¥å¤ò¥Ð¥¤¥Ñ¥¹¤¹¤ë¤À¤±¤Ë¤Ê¤ê¡¢
1437 ¥µ¡¼¥Ð¤Ï I/O ¤ò¥­¥ã¥Ã¥·¥å¤·¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1438 .\"O The client asks the server to make the I/O
1439 .\"O synchronous to preserve the synchronous semantics of
1440 .\"O .BR O_DIRECT .
1441 .\"O Some servers will perform poorly under these circumstances, especially
1442 .\"O if the I/O size is small.
1443 .\"O Some servers may also be configured to
1444 .\"O lie to clients about the I/O having reached stable storage; this
1445 .\"O will avoid the performance penalty at some risk to data integrity
1446 .\"O in the event of server power failure.
1447 .\"O The Linux NFS client places no alignment restrictions on
1448 .\"O .B O_DIRECT
1449 .\"O I/O.
1450 ¥¯¥é¥¤¥¢¥ó¥È¤Ï¡¢
1451 .B O_DIRECT
1452 ¤ÎƱ´üµ¡¹½¤òÊÝ»ý¤¹¤ë¤¿¤á¡¢¥µ¡¼¥Ð¤ËÂФ·¤Æ I/O ¤òƱ´ü¤·¤Æ¹Ô¤¦¤è¤¦¤Ë°ÍÍꤹ¤ë¡£
1453 ¥µ¡¼¥Ð¤Ë¤è¤Ã¤Æ¤Ï¡¢¤³¤¦¤·¤¿¾õ¶·²¼¡¢ÆäˠI/O ¥µ¥¤¥º¤¬¾®¤µ¤¤¾ì¹ç¤Ë
1454 À­Ç½¤¬Â礭¤¯Îô²½¤¹¤ë¡£
1455 ¤Þ¤¿¡¢¥µ¡¼¥Ð¤Ë¤è¤Ã¤Æ¤Ï¡¢I/O ¤¬°ÂÄꤷ¤¿¥¹¥È¥ì¡¼¥¸¤Ë¤Þ¤Ç¹Ô¤ï¤ì¤¿¤È¡¢
1456 ¥¯¥é¥¤¥¢¥ó¥È¤ËÂФ·¤Æ±³¤ò¤Ä¤¯¤â¤Î¤â¤¢¤ë¡£
1457 ¤³¤ì¤Ï¡¢¥µ¡¼¥Ð¤ÎÅŸ»¸Î¾ã¤¬µ¯¤³¤Ã¤¿ºÝ¤Ë¥Ç¡¼¥¿¤Î´°Á´À­¤¬Êݤ¿¤ì¤Ê¤¤
1458 ´í¸±¤Ï¾¯¤·¤¢¤ë¤¬¡¢À­Ç½Ì̤ǤÎÉÔÍø¤Ê¾ò·ï¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¹Ô¤ï¤ì¤Æ¤¤¤ë¡£
1459 Linux ¤Î NFS ¥¯¥é¥¤¥¢¥ó¥È¤Ç¤Ï
1460 .B O_DIRECT
1461 I/O 
1462 ¤Ç¤Î¥¢¥é¥¤¥ó¥á¥ó¥È¤ÎÀ©¸Â¤Ï¤Ê¤¤¡£
1463 .PP
1464 .\"O In summary,
1465 .\"O .B O_DIRECT
1466 .\"O is a potentially powerful tool that should be used with caution.
1467 .\"O It is recommended that applications treat use of
1468 .\"O .B O_DIRECT
1469 .\"O as a performance option which is disabled by default.
1470 ¤Þ¤È¤á¤ë¤È¡¢
1471 .B O_DIRECT
1472 ¤Ï¡¢Ãí°Õ¤·¤Æ»È¤¦¤Ù¤­¤Ç¤¢¤ë¤¬¡¢¶¯ÎϤʥġ¼¥ë¤È¤Ê¤ë²ÄǽÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡£
1473 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï
1474 .B O_DIRECT
1475 ¤ò¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï̵¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ëÀ­Ç½¸þ¾å¤Î¤¿¤á¤Î¥ª¥×¥·¥ç¥ó¤È
1476 ¹Í¤¨¤Æ¤ª¤¯¤Î¤¬¤è¤¤¤Ç¤¢¤í¤¦¡£
1477 .PP
1478 .RS
1479 .\"O "The thing that has always disturbed me about O_DIRECT is that the whole
1480 .\"O interface is just stupid, and was probably designed by a deranged monkey
1481 .\"O on some serious mind-controlling substances." \(em Linus
1482 ¡ÖO_DIRECT ¤Ç¤¤¤Ä¤âº¤¤ë¤Î¤Ï¡¢¥¤¥ó¥¿¥Õ¥§¡¼¥¹Á´Éô¤¬ËÜÅö¤Ë¤ªÇϼ¯¤ÊÅÀ¤À¡£
1483 ¤¿¤Ö¤ó´í¤Ê¤¤¥Þ¥¤¥ó¥É¥³¥ó¥È¥í¡¼¥ëºÞ¤Ç
1484 Ƭ¤¬¤ª¤«¤·¤¯¤Ê¤Ã¤¿¥µ¥ë¤¬À߷פ·¤¿¤ó¤¸¤ã¤Ê¤¤¤«¤Ê¡× \(em Linus
1485 .RE
1486 .\"O .SH BUGS
1487 .SH ¥Ð¥°
1488 .\"O Currently, it is not possible to enable signal-driven
1489 .\"O I/O by specifying
1490 .\"O .B O_ASYNC
1491 .\"O when calling
1492 .\"O .BR open ();
1493 .\"O use
1494 .\"O .BR fcntl (2)
1495 .\"O to enable this flag.
1496 ¸½ºß¤Î¤È¤³¤í¡¢
1497 .BR open ()
1498 ¤Î¸Æ¤Ó½Ð¤·»þ¤Ë
1499 .B O_ASYNC
1500 ¤ò»ØÄꤷ¤Æ¥·¥°¥Ê¥ë¶îÆ° I/O ¤òÍ­¸ú¤Ë¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
1501 ¤³¤Î¥Õ¥é¥°¤òÍ­¸ú¤Ë¤¹¤ë¤Ë¤Ï
1502 .BR fcntl (2)
1503 ¤ò»ÈÍѤ¹¤ë¤³¤È¡£
1504 .\" FIXME . Check bugzilla report on open(O_ASYNC)
1505 .\" See http://bugzilla.kernel.org/show_bug.cgi?id=5993
1506 .\"O .SH "SEE ALSO"
1507 .SH ´ØÏ¢¹àÌÜ
1508 .BR chmod (2),
1509 .BR chown (2),
1510 .BR close (2),
1511 .BR dup (2),
1512 .BR fcntl (2),
1513 .BR link (2),
1514 .BR lseek (2),
1515 .BR mknod (2),
1516 .BR mmap (2),
1517 .BR mount (2),
1518 .BR openat (2),
1519 .BR read (2),
1520 .BR socket (2),
1521 .BR stat (2),
1522 .BR umask (2),
1523 .BR unlink (2),
1524 .BR write (2),
1525 .BR fopen (3),
1526 .BR feature_test_macros (7),
1527 .BR fifo (7),
1528 .BR path_resolution (7),
1529 .BR symlink (7)