Topen tag [2] fid [2] mode [1] Ropen tag [2] fid [2] qid [8] Tcreate tag [2] fid [2] name [28] perm [4] mode [1] Rcreate tag [2] fid [2] qid [8]
The mode field expresses the type of I/O requested and is checked against the permissions for the file. Additional options can also be requested. The allowed values are shown below. If other bits are set in mode they will be ignored.
It is illegal to write a directory, truncate it, or attempt to remove it on close.
All these permissions are checked at the time of the open request; any subsequent changes to the permissions of files do not affect the ability to read, write, or remove an open file.
It is an error if the fid is already the product of a successful open or create message.
The permissions of the newly created file depend on the permissions of the enclosing directory (dir.perm) and the perm value of the request.
For non-directories, the formula is
(perm&(~8r777|8r111)) | (dir.perm&perm&8r666)For directories, the formula is
(perm&~8r777) | (dir.perm&perm&8r777)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. The 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 CHDIR bit (16r80000000) in the perm.
The names '.' and '..' are special. It is illegal to create files with these names.
It is an error 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. The create system call uses open with truncation. (see open, create - open/create a file for reading or writing in Chapter 8)
The algorithm used by the create system call is: