mount_null - demonstrate the use of a null file system layer
mount_null [-o options] target mount_point
The mount_null command creates a null layer, duplicating a
the file system namespace under another part of the global
namespace. It is implemented using a stackable layers technique, and its
``null-nodes'' stack above all lower-layer vnodes (not just
The options are as follows:
Options are specified with a -o flag followed by a
string of options. See the mount(8) man page for
and their meanings.
The null layer has two purposes. First, it serves as a
layering by proving a layer which does nothing. Second, the
can serve as a prototype layer. Since it provides all necessary layer
framework, new file system layers can be created very easily
with a null layer.
The remainder of this man page examines the null layer as a
constructing new layers.
INSTANTIATING NEW NULL LAYERS [Toc] [Back]
New null layers are created with mount_null. mount_null
takes two arguments:
the pathname of the lower vfs (target-pn) and the
the null layer will appear in the namespace (mount-pointpn). After the
null layer is put into place, the contents of target-pn subtree will be
aliased under mount-point-pn.
OPERATION OF A NULL LAYER [Toc] [Back]
The null layer is the minimum file system layer, simply bypassing all
possible operations to the lower layer for processing there.
of its activity centers on the bypass routine, through
all vnode operations pass.
The bypass routine accepts arbitrary vnode operations for
handling by the
lower layer. It begins by examining vnode operation arguments and replacing
any null-nodes by their lower-layer equivalents. It
the operation on the lower layer. Finally, it replaces the
the arguments and, if a vnode is returned by the operation,
null-node on top of the returned vnode.
Although bypass handles most operations, vop_getattr,
vop_reclaim, and vop_print are not bypassed. vop_getattr
must change the
fsid being returned. vop_inactive and vop_reclaim are not
that they can handle freeing null-layer specific data.
vop_print is not
bypassed to avoid excessive debugging information.
INSTANTIATING VNODE STACKS [Toc] [Back]
Mounting associates the null layer with a lower layer, in
two VFSes. Vnode stacks are instead created on demand as
files are accessed.
The initial mount creates a single vnode stack for the root
of the new
null layer. All other vnode stacks are created as a result
of vnode operations
on null vnode stacks.
New vnode stacks come into existence as a result of an operation which
returns a vnode. The bypass routine stacks a null-node
above the new vnode
before returning it to the caller.
For example, imagine mounting a null layer with
# mount_null /usr/include /dev/layer/null
Changing directory to /dev/layer/null will assign the root
(which was created when the null layer was mounted). Now
sys. A vop_lookup would be done on the root null-node.
would bypass through to the lower layer which would return a vnode
representing the UFS sys. Null_bypass then builds a nullnode aliasing
the UFS sys and returns this to the caller. Later operations on the
null-node sys will repeat this process when constructing
CREATING OTHER FILE SYSTEM LAYERS [Toc] [Back]
One of the easiest ways to construct new file system layers
is to make a
copy of the null layer, rename all files and variables, and
modifying the copy. sed(1) can be used to easily rename all
The umap layer is an example of a layer descended from the
INVOKING OPERATIONS ON LOWER LAYERS [Toc] [Back]
There are two techniques to invoke operations on a lower
layer when the
operation cannot be completely bypassed. Each method is appropriate in
different situations. In both cases, it is the responsibility of the
aliasing layer to make the operation arguments "correct" for
layer by mapping any vnode arguments to the lower layer.
The first approach is to call the aliasing layer's bypass
method is most suitable when you wish to invoke the operation currently
being handled on the lower layer. It has the advantage that
routine already must do argument mapping. An example of
null_getattrs in the null layer.
A second approach is to directly invoke vnode operations on
layer with the VOP_OPERATIONNAME interface. The advantage
of this method
is that it is easy to invoke arbitrary operations on the
The disadvantage is that vnodes arguments must be manually
mount(2), mount(8), umount(8)
UCLA Technical Report CSD-910056, Stackable Layers: an
File System Development.
The mount_null utility first appeared in 4.4BSD.
OpenBSD 3.6 April 19, 1994
[ Back ]