File: open.2

package info (click to toggle)
manpages-ja 0.4.0.0.20020315-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 14,808 kB
  • ctags: 4
  • sloc: sh: 9,595; perl: 157; makefile: 62
file content (421 lines) | stat: -rw-r--r-- 12,684 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
.\"                               1993 Michael Haardt, Ian Jackson.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified Wed Jul 21 22:42:16 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified Sun Aug 21 18:18:14 1994: Michael Haardt's NFS diffs were
.\"          applied by hand (faith@cs.unc.edu).
.\" Modified Sat Apr 13 16:25:28 1996 by Andries Brouwer (aeb@cwi.nl)
.\" Modified Mon May 13 00:53:52 1996: added symbolic constants
.\"          as sent by Thomas Koenig
.\" Modified Fri Dec 20 16:06:45 1996 by Michael Haardt: More NFS details
.\" Modified Fri Feb 19 15:08:34 1999 by Andries Brouwer (aeb@cwi.nl)
.\" Modified 981128 by Joseph S. Myers <jsm28@hermes.cam.ac.uk>
.\" Modified Thu Jun  3 19:29:06 1999 by Michael Haardt: NFS lock optimisation
.\"
.\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
.\"         all rights reserved.
.\" Translated Sat Aug 14 10:17:47 JST 1999
.\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated Fri May 25 19:52:26 JST 2001
.\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated & Modified Wed Jan  2 15:41:02 JST 2002 by Yuichi SATO
.\"
.\"WORD:	descriptor		ǥץ
.\"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	줿ܥå
.\"
.TH OPEN 2 1999-06-03 "Linux" "System calls"
.SH ̾
open, creat \- եޤϥǥХΥץ󡢺Ԥʤ
.SH 
.nf
.B #include <sys/types.h>
.B #include <sys/stat.h>
.B #include <fcntl.h>
.sp
.BI "int open(const char *" pathname ", int " flags );
.BI "int open(const char *" pathname ", int " flags ", mode_t " mode );
.BI "int creat(const char *" pathname ", mode_t " mode );
.fi
.SH 
.B open
ƥॳϥե̾ե롦ǥץ (³
.BR read ", " write 
ʤ I/O ǻѤ뾮) ؤѴ˻Ѥ롣
ƤӽФ硢ߤΥץˤäƥץ󤵤Ƥʤ
ե롦ǥץΤǾΤΤ֤
Υ¾ΥץȶͭƤʤץ󤵤줿ե
롣( 
.BR fork (2)
ƥॳѤƥץ󤵤줿եͭ뤳ȤϤǤ)
ե롦ǥץ exec ؿԤä open 줿
ޤޤǤ
.RB ( fcntl (2) 
򻲾)
ե롦եå (file offset) ϥեƬꤵ롣

ѥ᡼
.I flags

.BR O_RDONLY ", " O_WRONLY ", " O_RDWR
Τɤ줫Ĥǡ줾ɤ߹ѡ񤭹ѡɤ߽Ѥ׵᤹롣
.I flags
ϡʲ 0 İʾΥӥå OR (bitwise-or) Ǥ褤
.TP
.B O_CREAT
ե뤬¸ߤʤäϺ (create) 롣
եνͭ (桼 ID) ϡץμ¸桼 ID ꤵ롣
롼׽ͭ (롼 ID) ϡץμ¸롼 ID
ޤϿƥǥ쥯ȥΥ롼 ID ꤵ
(ϡե륷ƥॿסޥȥץ
ƥǥ쥯ȥΥ⡼ɤ˰¸롣
㤨С
.BR mount (8)
Ƥ ext2 ե륷ƥΥޥȥץ
.I bsdgroups

.I sysvgroups
򸫤)
.TP
.B O_EXCL
.B O_CREAT 
Ȱ˻Ѥ줿硢
ե뤬¸ߤϥ顼Ȥʤꡢ
.B open
ϼԤ롣
ξ硢ܥå󥯤ɤؤƤ뤫ˤ餺
Υܥå󥯤¸ߤ롣
.B O_EXCL
 NFS ե롦ƥǤϵǽʤ
å (lock) ǽʤɤ˻Ѥˤ϶֤ˤʤ
åեѤʬǽ (atomic) Υåǽβˤ
Ʊե롦ƥ¾̾νŤʤʤե
(㤨Хۥ̾ pid Ȥ߹碌) 
.BR link (2)
Ѥƥåե롣
\fBlink()\fP ֤ͤ 0 ʤХåƤ롣
ʳξϡΥե
.BR stat (2)
Ѥƥ󥯿 (link count)  2 ˤʤäƤ뤫å롣
ξˤϥåƤ롣
.TP
.B O_NOCTTY
.I pathname
ü (terminal) ǥХ򻲾ȤƤơ
\(em 
.BR tty (4)
򻲾Ȥ뤳
\(em 
ץüʤϡ줬üˤʤ롣
.TP
.B O_TRUNC
ե뤬¸ߤ̾եǤꡢ
񤭹߲ĥ⡼ɤǥץ󤵤Ƥ
(ĤޤꡢO_RDWR ޤ O_WRONLY ) 硢
Ĺ 0 ڤͤ (truncate) 롣
ե뤬 FIFO ޤüǥХեξ硢
O_TRUNC ե饰̵뤵롣
ʳξ硢O_TRUNC θ̤ϻꤵƤʤ
(Linux С¿ǤϡΥե饰̵뤵롣
ʳΥСǤϥ顼֤)
.TP
.B O_APPEND
եɲ (append) ⡼ɤǥץ󤹤롣줾
.B write

.B lseek
ԤäΤ褦ˡե롦ݥ󥿡եκǸ˰ư롣
NFS ե롦ƥǤϡ
.B O_APPEND
ʣΥץƱեƱ
񤭹⤦Ȥ硢Ƥ˲롣 NFS ɲå⡼ɤ
ݡȤ饤ȤΥͥ (kernel) 򥷥ߥ졼
ƤΤǡ֤ǤϻѤǤʤǤ롣
.TP
.BR O_NONBLOCK " ޤ " O_NDELAY
ǽʤСե (non-blocking) ⡼ɤǥץ󤵤롣
.B open
¾ΡΥե롦ǥץФ뤹٤Ƥ
ƤӽФץԤ뤳Ȥʤ֤롣
FIFO (͡ɡѥ) 򰷤ˤ
.BR fifo (4)
⻲Ȥ뤳ȡ
Υ⡼ɤ FIFO ʳΥեФƸ̤ɬפϤʤ
.TP
.B O_SYNC
եƱ (synchronous) I/O ⡼ɤǥץ󤵤롣
Υե롦ǥץФƤ
.BR write
ϡбϡɥʪŪ˽񤭹ޤޤǸƤӽФ
ץʤ
.I ʲΡ¡פ򸫤衣
.TP
.B O_NOFOLLOW
\fIpathname\fR ܥå󥯤ä硢ץϼԤ롣
 FreeBSD γĥǡLinux ˤ 2.1.126 ɲä줿
pathname ʬΥܥå󥯤ϰȤפ롣
glibc 2.0.100 ʹߤΥإåˤϤΥե饰롣
\fI2.1.126 ΥͥǻѤˤ̵뤵롣\fR
.TP
.B O_DIRECTORY
\fIpathname\fR ǥ쥯ȥǤʤХץϼԤ롣
Υե饰 Linux ͭǤ롣
\fBopendir\fR(3)  FIFO ơץǥХФƥ뤵줿
ӥǽ (denial-of-service) 򤱤뤿
ͥ 2.1.126 ɲä줿
 \fBopendir\fR μʳǤϻѤ٤ǤϤʤ
.TP
.B O_LARGEFILE
ʥե (Large Files System) 򥵥ݡȤ 32 ӥåȥƥǡ
31 ӥåȤǤϥեΥɽ碌ʤ褦ʥե
ץǽˤ롣
.PP
ե饰ΤĤϥե򥪡ץ󤷤Ǥ
.B fcntl
Ѥѹ뤳ȤǤ롣


.I mode
Ͽե˻Ѥ (permission) ꤹ롣
ϥץ 
.B umask
̤̾꽤졢줿եεĤ
.B "(mode & ~umask)" 
Ȥʤ롣
Υ⡼ɤϿ줿ե
ΥˤΤŬѤդ뤳ȡ
ɤ߹ߤΤߤΥե
.B open
ϡread/write ե롦ǥץ֤
.PP
.I mode 
Τ˰ʲΥܥ󶡤Ƥ :
.TP
.B S_IRWXU
00700 桼 (եνͭ) ɤ߹ߡ񤭹ߡ
¹ԤεĤġ
.TP
.B S_IRUSR (S_IREAD)
00400 桼ɤ߹ߤεĤġ
.TP
.B S_IWUSR (S_IWRITE)
00200 桼Ͻ񤭹ߤεĤġ
.TP
.B S_IXUSR (S_IEXEC)
00100 桼ϼ¹ԤεĤġ
.TP
.B S_IRWXG
00070 롼פɤ߹ߡ񤭹ߡ¹ԤεĤġ
.TP
.B S_IRGRP
00040 롼פɤ߹ߤεĤġ
.TP
.B S_IWGRP
00020 롼פϽ񤭹ߤεĤġ
.TP
.B S_IXGRP
00010 롼פϼ¹ԤεĤġ
.TP
.B S_IRWXO
00007 ¾ (others) ɤ߹ߡ񤭹ߡ¹ԤεĤġ
.TP
.B S_IROTH
00004 ¾ͤɤ߹ߤεĤġ
.TP
.B S_IWOTH
00002 ¾ͤϽ񤭹ߤεĤġ
.TP
.B S_IXOTH
00001 ¾ͤϼ¹ԤεĤġ
.PP
.I mode

.I flags 

.B O_CREAT
ꤵƤϾ˻ꤹɬפ롣
ʳξ̵뤵롣

.B creat

.I flags

.B O_CREAT|O_WRONLY|O_TRUNC
.B open
ԤʤΤǤ롣

.SH ֤
.BR open "  " creat
Ͽե롦ǥץ֤
顼ȯ \-1 ֤
.I errno
Ŭڤꤹ)
.B open
üե򥪡ץ󤹤뤳ȤϤǤ뤬
.B creat
üե뤳ȤϤǤʤȤդ뤳ȡ
- 
.BR mknod (2)
Ѥ롣
.LP
UID ޥåԥ󥰤ѤƤ NFS ե롦ƥǤϡ
\fBopen\fP ե롦ǥץ֤Ǥ
\fBread\fP(2)  \fBEACCES\fP ǵݤ礬롣
 \fBopen\fP εĤΥåϥ饤ȤǹԤʤƤ뤬
ɤ߹ߡ񤭹ߤκݤ UID ޥåԥ󥰤ϥСǹԤʤƤ뤿Ǥ롣

ե뤬ȡ
ե atime, ctime, mtime եɤ߻ꤵ롣
˿ƥǥ쥯ȥ ctime  mtime ⸽߻ꤵ롣
ʳξǡO_TRUNC ե饰ǥե뤬줿Ȥϡ
ե ctime  mtime եɤ߻ꤵ롣

.SH 顼
.TP
.B EEXIST
.I pathname
ϴ¸ߤ
.BR O_CREAT "  " O_EXCL
Ѥ줿
.TP
.B EISDIR
.I pathname
ϥǥ쥯ȥ򻲾ȤƤꡢ񤭹׵᤬ޤޤƤ
(Ĥޤ
.B O_WRONLY
ޤ
.B O_RDWR
ꤵƤ)
.TP
.B EACCES
եФ׵ᤵ줿Ƥʤ
.I pathname
Υǥ쥯ȥʬΤɤ줫˸ (¹) Ĥʤä
ޤϥե뤬ޤ¸ߤƥǥ쥯ȥؤν񤭹ߵĤʤä
.TP
.B ENAMETOOLONG
.IR pathname " Ĺ᤮롣"
.TP
.B ENOENT
O_CREAT ꤵƤ餺Ļꤵ줿ե뤬¸ߤʤ
ޤϡ
.I pathname
Υǥ쥯ȥʬ¸ߤʤ줿 (dangling) ܥå󥯤Ǥ롣
.TP
.B ENOTDIR
.I pathname
˴ޤޤǥ쥯ȥʬΤɤ줫ºݤˤϥǥ쥯ȥǤʤ
ޤ \fBO_DIRECTORY\fR ꤵƤꡢ
.I pathname
ǥ쥯ȥǤʤ
.TP
.B ENXIO
O_NONBLOCK | O_WRONLY ꤵƤꡢꤷե뤬 FIFO 
Υեɤ߹ߤΤ˥ץ󤷤Ƥץ¸ߤʤ
ޤϡե뤬ǥХüեбǥХ¸ߤʤ
.TP
.B ENODEV
.I pathname
ǥХüե򻲾ȤƤꡢбǥХ¸ߤʤ
( Linux ͥΥХǤꡢξˤ ENXIO ֤٤Ǥ)
.TP
.B EROFS
.I pathname
ɤ߹ѤΥե륷ƥΥե򻲾ȤƤꡢ
񤭹ߥ׵ᤷ
.TP
.B ETXTBSY
.I pathname
߼¹μ¹ԥ᡼򻲾ȤƤꡢ񤭹ߤ׵ᤷ
.TP
.B EFAULT
.IR pathname " ǽʥɥ쥹֤γؤƤ."
.TP
.B ELOOP
.I pathname
褹ݤܥå󥯤¿᤮롣
ޤ \fBO_NOFOLLOW\fR ꤵƤꡢ
.I pathname
ܥå󥯤ä
.TP
.B ENOSPC
.I pathname
ɬפ뤬
.I pathname
ޤǤǥХ˿եΤζ̤ʤ
.TP
.B ENOMEM
ͥ˽ʬ꤬¸ߤʤ
.TP
.B EMFILE
ץˡץǤեκãƤ롣
.TP
.B ENFILE
ƥΤǥץǤեι׿¤ãƤ롣
.SH 
SVr4, SVID, POSIX, X/OPEN, BSD 4.3
.B O_NOFOLLOW

.B O_DIRECTORY
ե饰 Linux ͭΤΤǤ롣
Υե饰Ȥˤˤϡ
.B _GNU_SOURCE
ޥɬפ뤫Τʤ
.SH 
NFS ¸Ƥץȥˤ¿ꡢä
.BR O_SYNC "  " O_NDELAY 
˱ƶ롣

POSIX Ǥϡե饰 \fBO_SYNC\fR, \fBO_DSYNC\fR, \fBO_RSYNC\fR б
3 Ʊ I/O 󶡤Ƥ롣
Linux ǤϡΤȤ (ͥ 2.1.130) ƱΤǤ롣
.SH Ϣ
.BR read (2),
.BR write (2),
.BR fcntl (2),
.BR close (2),
.BR link (2),
.BR mknod (2),
.BR mount (2),
.BR stat (2),
.BR umask (2),
.BR unlink (2),
.BR socket (2),
.BR fopen (3),
.BR fifo (4)