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
43 says to remove the file when it is closed (by everyone who has a copy of the file descriptor).
45 fails if the file does not exist or the user does not have
46 permission to open it for the requested purpose
49 for a description of permissions).
50 The user must have write permission on the
63 is actually identical to
69 or prepares to rewrite an existing
75 and returns an associated file descriptor.
77 the owner is set to the userid of the creating process group;
78 the group to that of the containing directory;
81 ANDed with the permissions of the containing directory.
82 If the file already exists,
83 it is truncated to 0 length,
84 and the permissions, owner, and group remain unchanged.
85 The created file is a directory if the
89 an exclusive-use file if the
91 bit is set, and an append-only file if the
94 Exclusive-use files may be open for I/O by only one client at a time,
95 but the file descriptor may become invalid if no I/O is done
96 for an extended period; see
100 fails if the path up to the last element of
102 cannot be evaluated, if the user doesn't have write permission
103 in the final directory, if the file already exists and
104 does not permit the access defined by
106 of if there there are no free file descriptors.
107 In the last case, the file may be created even when
108 an error is returned.
109 .\" If the file is new and the directory in which it is created is
110 .\" a union directory (see
112 .\" then the constituent directory where the file is created
113 .\" depends on the structure of the union: see
118 may succeed even if the file exists, a special mechanism is necessary
119 for those applications that require an atomic create operation.
127 the call succeeds only if the file does not already exist;
133 closes the file associated with a file descriptor.
134 Provided the file descriptor is a valid open descriptor,
136 is guaranteed to close it; there will be no error.
137 Files are closed automatically upon termination of a process;
139 allows the file descriptor to be reused.