bind, mount, unmount – change name space|
int bind(char *name, char *old, int flag)
int mount(int fd, int afd, char *old, int flag, char *aname)
int unmount(char *name, char *old)
Bind and mount modify the file name space of the current process
and other processes in its name space group (see fork(2)). For
both calls, old is the name of an existing file or directory in
the current name space where the modification is to be made. The
name old is evaluated as described in intro(2), except that no
translation of the final path element is done. |
For bind, name is the name of another (or possibly the same) existing file or directory in the current name space. After a successful bind call, the file name old is an alias for the object originally named by name; if the modification doesn't hide it, name will also still refer to its original file. The evaluation of new happens at the time of the bind, not when the binding is later used.
The fd argument to mount is a file descriptor of an open network connection or pipe to a file server, while afd is a authentication file descriptor as created by fauth(2) and subsequently authenticated. If authentication is not required, afd should be –1. The old file must be a directory. After a successful mount the file tree served (see below) by fd will be visible with its root directory having name old.
The flag controls details of the modification made to the name
space. In the following, new refers to the file as defined by
name or the root directory served by fd. Either both old and new
files must be directories, or both must not be directories. Flag
can be one of:
The flags are defined in <libc.h>. In addition, there is an MCREATE flag that can be OR'd with any of the above. When a create system call (see open(2)) attempts to create in a union directory, and the file does not exist, the elements of the union are searched in order until one is found with MCREATE set. The file is created in that directory; if that attempt fails, the create fails.
Finally, the MCACHE flag, valid for mount only, turns on caching for files made available by the mount. By default, file contents are always retrieved from the server. With caching enabled, the kernel may instead use a local cache to satisfy read(5) requests for files accessible through this mount point. The currency of cached data for a file is verified at each open(5) of the file from this client machine.
With mount, the file descriptor fd must be open for reading and writing and prepared to respond to 9P messages (see Section 5). After the mount, the file tree starting at old is served by a kernel mnt(3) device. That device will turn operations in the tree into messages on fd. Aname selects among different file trees on the server; the null string chooses the default tree.
The file descriptor fd is automatically closed by a successful mount call.
The effects of bind and mount can be undone by unmount. If name
is zero, everything bound to or mounted upon old is unbound or
unmounted. If name is not zero, it is evaluated as described above
for bind, and the effect of binding or mounting that particular
result on old is undone.
bind(1), intro(2), fcall(2), auth(2) (particularly amount), intro(5),
The return value is a positive integer (a unique sequence number)
for success, –1 for failure. These routines set errstr.|
Mount will not return until it has successfully attached to the
file server, so the process doing a mount cannot be the one serving.|