3 open, create, close \- open a file for reading or writing, create file
10 int open(char *file, int omode)
13 int create(char *file, int omode, ulong perm)
21 for I/O and returns an associated file descriptor.
29 asking for permission to read, write, read and write, or execute, respectively.
30 In addition, there are three values that can be ORed with the
33 says to truncate the file
34 to zero length before opening it;
36 says to close the file when an
42 says to remove the file when it is closed (by everyone who has a copy of the file descriptor);
45 says to open the file in append-only mode, so that writes
46 are always appended to the end of the file.
48 fails if the file does not exist or the user does not have
49 permission to open it for the requested purpose
52 for a description of permissions).
53 The user must have write permission on the
66 is actually identical to
72 or prepares to rewrite an existing
78 and returns an associated file descriptor.
80 the owner is set to the userid of the creating process group;
81 the group to that of the containing directory;
84 ANDed with the permissions of the containing directory.
85 If the file already exists,
86 it is truncated to 0 length,
87 and the permissions, owner, and group remain unchanged.
88 The created file is a directory if the
92 an exclusive-use file if the
94 bit is set, and an append-only file if the
97 Exclusive-use files may be open for I/O by only one client at a time,
98 but the file descriptor may become invalid if no I/O is done
99 for an extended period; see
103 fails if the path up to the last element of
105 cannot be evaluated, if the user doesn't have write permission
106 in the final directory, if the file already exists and
107 does not permit the access defined by
109 of if there there are no free file descriptors.
110 In the last case, the file may be created even when
111 an error is returned.
112 .\" If the file is new and the directory in which it is created is
113 .\" a union directory (see
115 .\" then the constituent directory where the file is created
116 .\" depends on the structure of the union: see
121 may succeed even if the file exists, a special mechanism is necessary
122 for those applications that require an atomic create operation.
130 the call succeeds only if the file does not already exist;
136 closes the file associated with a file descriptor.
137 Provided the file descriptor is a valid open descriptor,
139 is guaranteed to close it; there will be no error.
140 Files are closed automatically upon termination of a process;
142 allows the file descriptor to be reused.
152 Not all functionality is supported on all systems.
156 bit is not supported on any systems.
158 The implementation of
160 is to unlink the file after opening it, causing problems
161 in programs that try to access the file by name before it is closed.
163 To avoid name conflicts with the underlying system,
167 are preprocessor macros defined as