include "sys.m"; sys:= load Sys Sys->PATH; bind: fn (source, target: string, flag: int): int; mount:fn (fd: ref FD; target: string, flag: int, aname: string): int; unmount: fn(source, target: string): int;
bind (source, target, flag)
For bind, source is the name of an existing file or directory in the current name space. After a successful bind call, the file name target is an alias for the object originally named by source. If the modification doesn't hide the original, source will still refer to the original file. The evaluation of source happens at the time of the bind, not when the binding is used. mount (fd, target, flag, aname)
The fd argument to mount is a file descriptor of an open pipe or network connection to a file server ready to receive Styx messages. The target file must be a directory. After a successful mount the file tree served by fd will be visible with its root directory having name target.
After the mount, the file tree starting at target is served by a kernel mnt device. That device will turn operations in the tree into messages on fd.
Options for bind and mount
For both bind and mount, the flag controls details of the modification made to the name space. In the following descriptions, source refers to the file as defined by name or the root directory served by fd. Both target and source files must be directories, or both must non-directories. The flag parameter can be one of the following: MREPL
Replace the target file by the source. An evaluation of target will be translated to the source file. If they are directories target becomes a union directory consisting of one directory, the source file. MBEFORE
Both target and source must be directories. Add the files of the source directory to the union directory at target so its contents appear first in the union. After a bind or mount with this option, the source directory will be searched first when evaluating file names in the union directory. MAFTER
Like MBEFORE but the source directory goes at the end of the union. MCREATE
The MCREATE flag can be OR'ed with any of the flags previously described above. When a create call 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. (see open, create - open/create a file for reading or writing)
unmount (name, target)
The effects of bind and mount can be undone by unmount. If name is nil, everything bound to or mounted on target is unbound or unmounted. If name is not nil, it is evaluated as described above for bind, and the effect of binding or mounting that particular result on target is undone. Diagnostics
The return value is a positive integer (a unique sequence number) for success, -1 for failure. Caveat
The mount command will not return until it has successfully attached to the file server, so the thread doing a mount cannot be the one serving. Examples
See Examples in Chapter 5
See Also
Limbo System Module, bind, mount, unmount - change name space in Chapter 5