open, create - prepare a fid for I/O on a file — Inferno 1ed
open, create - prepare a fid for I/O on a file
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]
Description
The open Transaction
The open request asks the file server to check permissions and prepare a fid for I/O with subsequent read and write messages.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.
The create Transaction
The create request asks the file server to create a new file with the name supplied, in the directory (dir) represented by fid. This request and requires write permission in the directory. The owner of the file is the implied user id of the request and the group of the file is the same as dir.
(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:
- Walk to the directory to contain the file. If that fails, return an error.
- Walk to the specified file. If the walk succeeds, send a request to open (with the truncate option) 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 (with the truncate option) again. For the behavior of create on a union directory, (See bind, mount, unmount - change file name space in Chapter 8).
Entry Points
The open and create calls both generate open messages; only the create call generates a create message.
See Also
|
bind, mount, unmount - change file name space in Chapter 8
|
|
open, create - open/create a file for reading or writing in Chapter 8
|
|
stat, wstat - inquire or change file attributes
|
infernosupport@lucent.com Copyright © 1996,Lucent Technologies, Inc. All rights reserved.