[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

bind, mount, unmount - change name space

bind    [-rabc] source target
mount   [-rabc] [-C cryptoalg] net!machine mountpoint
unmount [source] target

Description

The bind and mount commands modify the file name space of the current process and other processes in the same name space group (see pctl - process control in Chapter 8). For both calls, target is the name of an existing file or directory in the current name space.

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.

bind command

For bind, source is the name of an existing file or directory in the current name space. After a successful bind, the file name target is an alias for the object originally named by source; if the modification doesn't hide it, source will also still refer to its original file. The evaluation of source (see File name expansion in sh - command line interface to the Inferno system) happens at the time of the bind, not when the binding is later used.

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

mount command

The mount command must be used before binding to a remote computer. However, before the mount command is given you must setup your computer with the IP device driver to communicate over the network. For example:

bind -a `#I' /net

If 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!machine

The 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!machine

if that file exists. Otherwise, mount will attempt to find a certificate in the file

/usr/<username>/keyring/default  

That 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.

mount [options] net!machine mountpoint

The mount command requires a network address for the server machine in the form:

net!machine

net
The net component defines the network to be used (for example - tcp, udp). The special value net can be supplied to request the most expedient network. Currently, net is synonymous with tcp.

machine
The machine component can be any of the following
numeric internet address Used verbatim.
hostname Converted to network address, by issuing a lib/cs command prior to the mount command.
symbolic server name of the form $server Converted to hostname by reference to the connection server database file /services/cs/db. The hostname returned is then converted to an network address. No machine name is converted. Other conversions (for example, 'net' and named services) are still done.
:

In general, network addresses in Inferno have three components.

	net!machine!service

See 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.

Options
-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.
for bind and mount

Caveat

The single quotes are required around the two character sequence representing a kernel device driver since # is a special character (start-of-comment) to the Inferno shell. The single quotes are needed only when using the shell, not when programming in the Limbo language.

	sys->bind("#c", "/dev", flags);

Examples

The next few examples explore name space operations with the bind command.

The bind command: replace

The syntax of the bind command is with the -r option is:

	bind -r source target

This 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.

Figure 5-1 Binding One Directory to Another
Assuming the current directory is E, the command to bind directory B to D is:

	bind A/B C/D

or

	bind -r A/B C/D

Afterwards, 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.

Figure 5-2 Accessing fileB By the Path C/D/
The contents of directory D have been replaced with those of directory B.

The bind command: unions

When bind command is used with either the -a 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/D

results in a union of the contents of two directories, as illustrated in Figure 5-3.

Figure 5-3 Union of the Contents of Directories A/B and C/D
The bind operation can be repeated to create the union of several directories at D.

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_com

As 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$

See Also

Namespace Operations in Chapter 8
sh - command line interface to the Inferno system
auth, readauthinfo, writeauthinfo - authenticate a connection in Chapter 9
newns - build a new name space from a description file in Chapter 15
nsbuild - build Inferno name space
byte2char, char2byte - conversion functions in Chapter 8
dial, announce, export, listen - network connections in Chapter 8


[Top] [Prev] [Next] [Bottom]

infernosupport@lucent.com
Copyright © 1997, Lucent Technologies, Inc.. All rights reserved.