bind [-rabc] source target mount [-rabc] [-C cryptoalg] net!machine mountpoint unmount [source] target
The effects of bind and mount can be undone with the unmount command. If two arguments are given to unmount, the effect is to undo a bind or mount with the same arguments. If only one argument is given, everything bound to or mounted upon target is unmounted.
Both target and source must be of the same type: either both directories or both files.
The source argument to bind can also be a two character sequence (#c) representing a kernel device driver (see Limbo Miscellaneous Modules in Chapter 15). For example, the following command binds the console driver to /dev:
bind '#c' /dev
bind -a `#I' /netIf you wish to have an authenticated connection to the remote computer, you must issue the getauthinfo command (see getauthinfo - obtain a certificate for authentication in Chapter 9). For example:
getauthinfo net!machineThe argument to the getauthinfo command is used to construct a filename for storing the certificate received from the certificate authority. The mount command will use the certificate in the file
/usr/<username>/keyring/net!machineif that file exists. Otherwise, mount will attempt to find a certificate in the file
/usr/<username>/keyring/defaultThat argument must match exactly the argument to be given as addr when the mount command is called; otherwise, mount will be unable to find that certificate.
net!machine
In general, network addresses in Inferno have three components.
net!machine!serviceSee dial, announce, export, listen - network connections in Chapter 8.
For the mount command, the service needed is provided by contacting the styx port on the server. The mount command appends the required service name to the net!machine components it receives as its address argument. It is unnecessary and erroneous to append the styx suffix to that argument.
-r |
Replace the target file by the source file. An evaluation of pathname target will be translated to the source file. If they are directories (for mount, this condition is true by definition), target becomes a union directory consisting of one directory (the source directory). This is the default option for both bind and mount (Both source and target must be either files or directories) |
-b |
Add the source directory to the beginning of the union directory represented by the target directory (Both source and target must be directories). |
-a |
Add the source directory to the end of the union directory represented by the target file. (Both source and target must be directories.) |
-c |
This can be used in addition to any of the above to permit creation in a union directory. When a source file is created in a union directory, it is placed in the first element of the union that permits creation.
For example, this command permits creation of files in dirb:
bind -ac dirb dirc |
-C alg |
For mount only, specify the algorithm, alg, used in authentication. See ssl - secure sockets layer device in Chapter 2 for the supported algorithms. The default value is none.
|
sys->bind("#c", "/dev", flags);
bind -r source targetThis has the same results as the bind command without any options.
The source and target arguments are assumed to be existing directories. A simple case of binding one directory to another is illustrated in Figure 5-1. The sample configuration has two sub-trees A and C rooted (for convenience) in the common directory E.
bind A/B C/Dor
bind -r A/B C/DAfterwards, an examination of the file tree (for example using the ls command) shows that directory D is a synonym for B, as illustrated in Figure 5-2. The name of the target directory is unchanged, but its contents are the same as those in the source directory. Accessing fileB by the path A/B/fileB remains valid.
Note that fileB is not copied to directory D: the bind command makes the file accessible via the path C/D.
or -b options the effect is not to replace the target but to create a union of the contents of the source and target at the target directory. (The difference between the options is not of immediate importance and will be discussed below.) Thus,
bind -b A/B C/Dresults in a union of the contents of two directories, as illustrated in Figure 5-3.
The inverse operation to bind is unmount. If called with two arguments, the unmount
command will remove the source directory named in the first argument from the target (union) directory named in the second argument. If only one argument is given, all bindings to the target (union) directory are removed.
The choice of the -a or -b option is important only if the source and target directories have some files with identical names. This feature is explored in the scenarios below.
In the first example, a series of commands creates a set of directories and files corresponding to the previous illustrations. Additionally, a file with a common name (file_com) but different contents is created in directories B and D.
$ mkdir A A/B C C/D $ >A/fileA; $ >C/fileC; $ >A/B/fileB $ >C/D/fileD $ echo 'hello, world!' > A/B/file_com $ echo 'how are you?' > C/D/file_comAs before, a union directory is created at D using bind with the -b option. A directory listing of that directory shows two entries for file_com; however, the pathname C/D/file_com leads to just one file.
Since the source directory was bound 'before' (-b) that of the target, its file supersede those of the target. The cat command shows (by content) that the pathname C/D/file_com is resolved to the file corresponding to pathname A/B/file_com.
$ bind -b A/B C/D $ ls -l C/D -rwxrwxrwx U 0 Everyone Everyone 0 Jan 21 16:10 C/D/fileB -rwxrwxrwx U 0 Everyone Everyone 0 Jan 21 16:10 C/D/fileD -rwxrwxrwx U 0 Everyone Everyone 14 Jan 21 16:10 C/D/file_com -rwxrwxrwx U 0 Everyone Everyone 13 Jan 21 16:10 C/D/file_com xxx$ cat C/D/file_com hello, world!When the binding is undone and redone with the -a ('after') option, the cat command shows that file originally in the directory has precedent when pathnames are resolved.
xxx$ unmount C/D xxx$ bind -a A/B C/D xxx$ ls -l C/D -rwxrwxrwx U 0 Everyone Everyone 0 Jan 21 16:10 C/D/fileB -rwxrwxrwx U 0 Everyone Everyone 0 Jan 21 16:10 C/D/fileD -rwxrwxrwx U 0 Everyone Everyone 13 Jan 21 16:10 C/D/file_com -rwxrwxrwx U 0 Everyone Everyone 14 Jan 21 16:10 C/D/file_com xxx$ cat C/D/file_com how are you? xxx$