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
|
.\" 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>
.\"
.\"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 "June 3, 1999" "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 ǻѤ뾮)ؤѴ˻Ѥ롣
."\O When the call is successful, the file descriptor returned will be
."\O the lowest file descriptor not currently open for the process.
ƤӽФ硢ߤΥץˤäƥץƤʤ
ե롦ǥץΤǾΤΤ֤
."\O This call creates a new open file, not shared with any other process.
."\O (But shared open files may arise via the
."\O .BR fork (2)
."\O system call.)
."\O The new file descriptor is set to remain open across exec functions
."\O (see
."\O .BR fcntl (2)).
."\O The file offset is set to the beginning of the file.
Υ¾ΥץȶͭƤʤץ줿ե
롣(
.BR fork (2)
ƥॳѤƥץ줿եͭ뤳ȤϤǤ)
ե롦ǥץ exec ؿԤä open 줿
ޤޤǤ(
.BR fcntl (2)
)
ե롦եå(file offset)ϥեƬꤵ롣
.I flags
.BR O_RDONLY ", " O_WRONLY ", " O_RDWR
Τɤ줫Ĥǡ줾ɤ߹ѡѡɤ߽Ѥ᤹롣
.I flags
Ϥ˰ʲΰİʾΥӥåOR(bitwise-or)Ǥ褤
.TP
.B O_CREAT
ե뤬¸ߤʤäϺ(create)롣
.TP
.B O_EXCL
.BR 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
ե뤬¸ߤ硢ڤͤ(truncate)롣
.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)
⻲Ȥ뤳ȡ
.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 ʹߤΥإåˤϤΥե饰롣
\fI 2.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 ӥåȤǤϥեΥɽ碌ʤ
Linux ͥ(2.1.130Ǥ)ޤݡȤƤʤե饰
¸ߤglibc 2.1 Υƥȥˤϥ桼 LFS Υե
¸ߤƤ롣
.PP
ե饰ΤĤϥեץǤ
.B fcntl
Ѥѹ뤳ȤǤ롣
.I mode
Ͽե˻Ѥ(permission)ꤹ롣
ϥץ
.BR umask
̤̾꽤졢줿եεĤ
.BR "(mode & ~umask)"
Ȥʤ롣
.PP
.IR 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
.IR flags
.B O_CREAT
ꤵƤϾ
ꤹɬפ롣ʳξ̵뤵롣
.B creat
.I flags
.BR 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 ޥåԥϥСǹԤʤƤ뤿Ǥ롣
.SH 顼
.TP
.B EEXIST
.I pathname
ϴ¸ߤ
.BR O_CREAT " " O_EXCL
Ѥ줿
.TP
.B EISDIR
.I pathname
ϥǥ쥯ȥȤƤꡢޤޤƤ
.TP
.B EACCES
եФᤵ줿Ƥʤ
.IR pathname
Υǥ쥯ȥʬΤɤ줫˸(¹)Ĥʤäޤϥե뤬
ޤ¸ߤƥǥ쥯ȥؤνߵĤʤä
.TP
.B ENAMETOOLONG
.IR pathname " Ĺ롣"
.TP
.B ENOENT
.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
.IR 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
.SH
NFS ¸Ƥץȥˤ¿ꡢä
.BR O_SYNC " " O_NDELAY
˱ƶ롣
.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)
|