source: trunk/minix/man/man2/open.2@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 4.9 KB
RevLine 
[9]1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)open.2 6.4 (Berkeley) 5/14/86
6.\"
7.TH OPEN 2 "May 14, 1986"
8.UC 4
9.SH NAME
10open \- open a file for reading or writing, or create a new file
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <fcntl.h>
16
17int open(const char *\fIpath\fP, int \fIflags\fP \fR[\fP, mode_t \fImode\fP\fR]\fP)
18.ft R
19.fi
20.SH DESCRIPTION
21.B Open
22opens the file
23.I path
24for reading and/or writing, as specified by the
25.I flags
26argument and returns a descriptor for that file.
27The
28.I flags
29argument may indicate the file is to be
30created if it does not already exist (by specifying the
31O_CREAT flag), in which case the file is created with mode
32.I mode
33as described in
34.BR chmod (2)
35and modified by the process' umask value (see
36.BR umask (2)).
37.PP
38.I Path
39is the address of a string of ASCII characters representing
40a path name, terminated by a null character.
41The flags specified are formed by
42.IR or 'ing
43the following values
44.PP
45.RS
46.ta +12n
47.nf
48O_RDONLY open for reading only
49O_WRONLY open for writing only
50O_RDWR open for reading and writing
51O_NONBLOCK do not block on open
52O_APPEND append on each write
53O_CREAT create file if it does not exist
54O_TRUNC truncate size to 0
55O_EXCL error if create and file exists
56.fi
57.DT
58.RE
59.PP
60Opening a file with O_APPEND set causes each write on the file
61to be appended to the end. If O_TRUNC is specified and the
62file exists, the file is truncated to zero length.
63If O_EXCL is set with O_CREAT, then if the file already
64exists, the open returns an error. This can be used to
65implement a simple exclusive access locking mechanism.
66If O_EXCL is set and the last component of the pathname is
67a symbolic link, the open will fail even if the symbolic
68link points to a non-existent name.
69If the O_NONBLOCK flag is specified and the open call would result
70in the process being blocked for some reason, the open returns immediately.
71.PP
72Upon successful completion a non-negative integer termed a
73file descriptor is returned.
74The file pointer used to mark the current position within the
75file is set to the beginning of the file.
76.PP
77The new descriptor is set to remain open across
78.BR execve
79system calls; see
80.BR close (2).
81.PP
82The system imposes a limit on the number of descriptors
83open simultaneously by one process.
84.SH "ERRORS
85The named file is opened unless one or more of the
86following are true:
87.TP 15
88[ENOTDIR]
89A component of the path prefix is not a directory.
90.TP 15
91[ENAMETOOLONG]
92The path name exceeds PATH_MAX characters.
93.TP 15
94[ENOENT]
95O_CREAT is not set and the named file does not exist.
96.TP 15
97[ENOENT]
98A component of the path name that must exist does not exist.
99.TP 15
100[EACCES]
101Search permission is denied for a component of the path prefix.
102.TP 15
103[EACCES]
104The required permissions (for reading and/or writing)
105are denied for the named file.
106.TP 15
107[EACCES]
108O_CREAT is specified,
109the file does not exist,
110and the directory in which it is to be created
111does not permit writing.
112.TP 15
113[EACCES]
114A device to be opened for writing is physically write protected.
115.TP 15
116[ELOOP]
117Too many symbolic links were encountered in translating the pathname.
118(Minix-vmd)
119.TP 15
120[EISDIR]
121The named file is a directory, and the arguments specify
122it is to be opened for writing.
123.TP 15
124[EROFS]
125The named file resides on a read-only file system,
126and the file is to be modified.
127.TP 15
128[EMFILE]
129The system limit for open file descriptors per process has already been reached.
130.TP 15
131[ENFILE]
132The system file table is full.
133.TP 15
134[ENXIO]
135The named file is a character special or block
136special file, and the device associated with this special file
137does not exist.
138.TP 15
139[ENOSPC]
140O_CREAT is specified,
141the file does not exist,
142and the directory in which the entry for the new file is being placed
143cannot be extended because there is no space left on the file
144system containing the directory.
145.TP 15
146[ENOSPC]
147O_CREAT is specified,
148the file does not exist,
149and there are no free inodes on the file system on which the
150file is being created.
151.ig
152.TP 15
153[EDQUOT]
154O_CREAT is specified,
155the file does not exist,
156and the directory in which the entry for the new fie
157is being placed cannot be extended because the
158user's quota of disk blocks on the file system
159containing the directory has been exhausted.
160.TP 15
161[EDQUOT]
162O_CREAT is specified,
163the file does not exist,
164and the user's quota of inodes on the file system on
165which the file is being created has been exhausted.
166..
167.TP 15
168[EIO]
169An I/O error occurred while making the directory entry or
170allocating the inode for O_CREAT.
171.TP 15
172[EFAULT]
173.I Path
174points outside the process's allocated address space.
175.TP 15
176[EEXIST]
177O_CREAT and O_EXCL were specified and the file exists.
178.SH "SEE ALSO"
179.BR chmod (2),
180.BR close (2),
181.BR dup (2),
182.BR fcntl (2),
183.BR lseek (2),
184.BR read (2),
185.BR write (2),
186.BR umask (2).
Note: See TracBrowser for help on using the repository browser.