size Rcreate tag qid iounit
The create request asks the file server to create a new file with the name supplied, in the directory (dir) represented by fid, and requires write permission in the directory. The owner of the file is the implied user id of the request, the group of the file is the same as dir, and the permissions are the value of perm & (~8r666 | (dir.perm & 8r666)) if a regular file is being created and perm & (~8r777 | (dir.perm & 8r777)) if a directory is being created. This means, for example, that if the create allows read permission to others, but the containing directory does not, then the created file will not allow others to read the file.
Finally, the newly created file is opened according to mode, and fid will represent the newly opened file. Mode is not checked against the permissions in perm. The qid for the new file is returned with the create reply message.
Directories are created by setting the DMDIR bit (16r80000000) in the perm.
The names . and .. are special; it is illegal to create files with these names.
It is an error for either of these messages if the fid is already the product of a successful open or create message.
An attempt to create a file in a directory where the given name already exists will be rejected; in this case, the create system call (see sys-open(2)) uses open with truncation. The algorithm used by the create system call is: first walk to the directory to contain the file. If that fails, return an error. Next walk to the specified file. If the walk succeeds, send a request to open and truncate the file and return the result, successful or not. If the walk fails, send a create message. If that fails, it may be because the file was created by another process after the previous walk failed, so (once) try the walk and open again.
For the behavior of create on a union directory, see sys-bind(2).
The iounit field returned by open and create may be zero. If it is not, it is the maximum number of bytes that are guaranteed to be read from or written to the file without breaking the I/O transfer into multiple Styx messages; see read(5).
For programs that need atomic file creation, without the race that exists in the open-create sequence described above, the kernel does the following. If the OEXCL (16r1000) bit is set in the mode for a create system call, the open message is not sent; the kernel issues only the create. Thus, if the file exists, create will draw an error, but if it doesn't and the create system call succeeds, the process issuing the create is guaranteed to be the one that created the file.
|OPEN(5)||Rev: Thu Feb 15 14:43:43 GMT 2007|