[Top] [Prev] [Next]

bind, mount, unmount - change name space

bind               [option... ] source target
mount              [option... ] addr target
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,. In the mount command, source is a network address for the server machine in the form:

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 login, getauthinfo get an Authinfo adt from a certificate authority). For example: getauthinfo net!machine

mount [option] addr target

In the mount command, addr is a network address for the server machine in the form: net!destination!service.

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.

service

A service name or port number. The default is Styx
numeric port value

Used verbatim.

Service name

Converted to a port number.

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.

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

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.

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.

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.

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.

xxx$ mkdir A A/B C C/D
xxx$ >A/fileA;
xxx$ >C/fileC;
xxx$ >A/B/fileB
xxx$ >C/D/fileD
xxx$ echo 'hello, world!' > A/B/file_com
xxx$ 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.

xxx$ bind -b 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 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
sh - command line interface to the Inferno system

auth, readauthinfo, writeauthinfo - authenticate a connection in Chapter 9

Limbo System Module in Chapter 8

bind, mount, unmount - change file name space in Chapter 8

dial, announce, export, listen - make network connections

Limbo Miscellaneous Modules in Chapter 15



[Top] [Prev] [Next]

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