2005-01-31 08:19:18 +03:00
|
|
|
.\" $NetBSD: mount_null.8,v 1.21 2005/01/31 05:19:19 erh Exp $
|
1994-06-08 23:23:02 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1992, 1993, 1994
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software donated to Berkeley by
|
|
|
|
.\" John Heidemann of the UCLA Ficus project.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2003-08-07 14:04:22 +04:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-06-08 23:23:02 +04:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1997-09-16 16:26:56 +04:00
|
|
|
.\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95
|
1994-06-14 02:50:46 +04:00
|
|
|
.\"
|
1997-09-16 16:26:56 +04:00
|
|
|
.\"
|
|
|
|
.Dd May 1, 1995
|
1994-06-08 23:23:02 +04:00
|
|
|
.Dt MOUNT_NULL 8
|
2001-06-05 15:22:41 +04:00
|
|
|
.Os
|
1994-06-08 23:23:02 +04:00
|
|
|
.Sh NAME
|
|
|
|
.Nm mount_null
|
1997-09-16 16:26:56 +04:00
|
|
|
.Nd mount a loopback filesystem sub-tree;
|
|
|
|
demonstrate the use of a null file system layer
|
1994-06-08 23:23:02 +04:00
|
|
|
.Sh SYNOPSIS
|
2001-11-16 15:00:10 +03:00
|
|
|
.Nm
|
1994-06-08 23:23:02 +04:00
|
|
|
.Op Fl o Ar options
|
|
|
|
.Ar target
|
|
|
|
.Ar mount-point
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
1997-09-15 09:35:37 +04:00
|
|
|
.Nm
|
1994-06-08 23:23:02 +04:00
|
|
|
command creates a
|
|
|
|
null layer, duplicating a sub-tree of the file system
|
|
|
|
name space under another part of the global file system namespace.
|
1997-09-16 16:26:56 +04:00
|
|
|
This allows existing files and directories to be accessed
|
|
|
|
using a different pathname.
|
|
|
|
.Pp
|
|
|
|
The primary differences between a virtual copy of the filesystem
|
|
|
|
and a symbolic link are that
|
|
|
|
.Xr getcwd 3
|
|
|
|
functions correctly in the virtual copy, and that other filesystems
|
|
|
|
may be mounted on the virtual copy without affecting the original.
|
|
|
|
A different device number for the virtual copy is returned by
|
|
|
|
.Xr stat 2 ,
|
|
|
|
but in other respects it is indistinguishable from the original.
|
|
|
|
.Pp
|
|
|
|
The
|
1997-10-20 13:11:16 +04:00
|
|
|
.Nm
|
1997-09-16 16:26:56 +04:00
|
|
|
filesystem differs from a traditional
|
|
|
|
loopback file system in two respects: it is implemented using
|
2001-11-16 13:25:42 +03:00
|
|
|
a stackable layers technique, and its
|
1994-06-08 23:23:02 +04:00
|
|
|
.Do
|
1995-07-12 11:08:27 +04:00
|
|
|
null-nodes
|
|
|
|
.Dc
|
1994-06-08 23:23:02 +04:00
|
|
|
stack above
|
1995-07-12 11:08:27 +04:00
|
|
|
all lower-layer vnodes (not just above directory vnodes).
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pp
|
2005-01-31 08:19:18 +03:00
|
|
|
Both
|
|
|
|
.Ar target
|
|
|
|
and
|
|
|
|
.Ar mount-point
|
|
|
|
are converted to absolute paths before use.
|
|
|
|
.Pp
|
1994-06-08 23:23:02 +04:00
|
|
|
The options are as follows:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fl o
|
|
|
|
Options are specified with a
|
|
|
|
.Fl o
|
|
|
|
flag followed by a comma separated string of options.
|
|
|
|
See the
|
|
|
|
.Xr mount 8
|
|
|
|
man page for possible options and their meanings.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The null layer has two purposes.
|
2001-06-07 17:58:23 +04:00
|
|
|
First, it serves as a demonstration of layering by providing a layer
|
1994-06-08 23:23:02 +04:00
|
|
|
which does nothing.
|
|
|
|
Second, the null layer can serve as a prototype layer.
|
|
|
|
Since it provides all necessary layer framework,
|
2001-06-07 17:58:23 +04:00
|
|
|
new file system layers can be created very easily by starting
|
1994-06-08 23:23:02 +04:00
|
|
|
with a null layer.
|
|
|
|
.Pp
|
|
|
|
The remainder of this man page examines the null layer as a basis
|
|
|
|
for constructing new layers.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh INSTANTIATING NEW NULL LAYERS
|
2001-11-16 13:25:42 +03:00
|
|
|
New null layers are created with
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm .
|
1997-10-20 13:11:16 +04:00
|
|
|
.Nm
|
1994-06-08 23:23:02 +04:00
|
|
|
takes two arguments, the pathname
|
|
|
|
of the lower vfs (target-pn) and the pathname where the null
|
2002-10-01 17:40:23 +04:00
|
|
|
layer will appear in the namespace (mount-point-pn).
|
|
|
|
After the null layer is put into place, the contents
|
1994-06-08 23:23:02 +04:00
|
|
|
of target-pn subtree will be aliased under mount-point-pn.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh OPERATION OF A NULL LAYER
|
|
|
|
The null layer is the minimum file system layer,
|
2002-03-30 18:28:35 +03:00
|
|
|
simply passing all possible operations to the lower layer
|
2002-10-01 17:40:23 +04:00
|
|
|
for processing there.
|
|
|
|
The majority of its activity centers on the bypass routine,
|
|
|
|
through which nearly all vnode operations pass.
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pp
|
|
|
|
The bypass routine accepts arbitrary vnode operations for
|
2002-10-01 17:40:23 +04:00
|
|
|
handling by the lower layer.
|
|
|
|
It begins by examining vnode operation arguments and replacing
|
|
|
|
any null-nodes by their lower-layer equivalents.
|
|
|
|
It then invokes the operation on the lower layer.
|
|
|
|
Finally, it replaces the null-nodes
|
1994-06-08 23:23:02 +04:00
|
|
|
in the arguments and, if a vnode is returned by the operation,
|
|
|
|
stacks a null-node on top of the returned vnode.
|
|
|
|
.Pp
|
2001-11-16 13:25:42 +03:00
|
|
|
Although bypass handles most operations,
|
|
|
|
.Em vop_getattr ,
|
1994-06-08 23:23:02 +04:00
|
|
|
.Em vop_inactive ,
|
|
|
|
.Em vop_reclaim ,
|
|
|
|
and
|
|
|
|
.Em vop_print
|
|
|
|
are not bypassed.
|
2001-06-07 17:58:23 +04:00
|
|
|
.Em vop_getattr
|
1994-06-08 23:23:02 +04:00
|
|
|
must change the fsid being returned.
|
2001-06-07 17:58:23 +04:00
|
|
|
.Em vop_inactive
|
1994-06-08 23:23:02 +04:00
|
|
|
and vop_reclaim are not bypassed so that
|
|
|
|
they can handle freeing null-layer specific data.
|
2001-06-07 17:58:23 +04:00
|
|
|
.Em vop_print
|
1994-06-08 23:23:02 +04:00
|
|
|
is not bypassed to avoid excessive debugging
|
|
|
|
information.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh INSTANTIATING VNODE STACKS
|
|
|
|
Mounting associates the null layer with a lower layer,
|
2002-10-01 17:40:23 +04:00
|
|
|
in effect stacking two VFSes.
|
|
|
|
Vnode stacks are instead
|
1994-06-08 23:23:02 +04:00
|
|
|
created on demand as files are accessed.
|
|
|
|
.Pp
|
|
|
|
The initial mount creates a single vnode stack for the
|
2002-10-01 17:40:23 +04:00
|
|
|
root of the new null layer.
|
|
|
|
All other vnode stacks
|
1994-06-08 23:23:02 +04:00
|
|
|
are created as a result of vnode operations on
|
|
|
|
this or other null vnode stacks.
|
|
|
|
.Pp
|
|
|
|
New vnode stacks come into existence as a result of
|
2001-11-16 13:25:42 +03:00
|
|
|
an operation which returns a vnode.
|
1994-06-08 23:23:02 +04:00
|
|
|
The bypass routine stacks a null-node above the new
|
|
|
|
vnode before returning it to the caller.
|
|
|
|
.Pp
|
|
|
|
For example, imagine mounting a null layer with
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
mount_null /usr/include /dev/layer/null
|
|
|
|
.Ed
|
2001-11-16 13:25:42 +03:00
|
|
|
Changing directory to
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pa /dev/layer/null
|
|
|
|
will assign
|
|
|
|
the root null-node (which was created when the null layer was mounted).
|
2001-11-16 13:25:42 +03:00
|
|
|
Now consider opening
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pa sys .
|
2002-10-01 17:40:23 +04:00
|
|
|
A vop_lookup would be done on the root null-node.
|
|
|
|
This operation would bypass through to the lower layer
|
|
|
|
which would return a vnode representing the UFS
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pa sys .
|
2002-10-01 17:40:23 +04:00
|
|
|
null_bypass then builds a null-node aliasing the UFS
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pa sys
|
|
|
|
and returns this to the caller.
|
2001-11-16 13:25:42 +03:00
|
|
|
Later operations on the null-node
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pa sys
|
2002-10-01 17:40:23 +04:00
|
|
|
will repeat this process when constructing other vnode stacks.
|
1994-06-08 23:23:02 +04:00
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh CREATING OTHER FILE SYSTEM LAYERS
|
|
|
|
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
|
2001-06-07 17:58:23 +04:00
|
|
|
then begin modifying the copy.
|
|
|
|
.Xr sed 1
|
|
|
|
can be used to easily rename all variables.
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pp
|
2001-11-16 13:25:42 +03:00
|
|
|
The umap layer is an example of a layer descended from the
|
1994-06-08 23:23:02 +04:00
|
|
|
null layer.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh INVOKING OPERATIONS ON LOWER LAYERS
|
2001-11-16 13:25:42 +03:00
|
|
|
There are two techniques to invoke operations on a lower layer
|
2002-10-01 17:40:23 +04:00
|
|
|
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
|
1994-06-08 23:23:02 +04:00
|
|
|
the operation arguments "correct" for the lower layer
|
2001-06-07 17:58:23 +04:00
|
|
|
by mapping any vnode arguments to the lower layer.
|
1994-06-08 23:23:02 +04:00
|
|
|
.Pp
|
|
|
|
The first approach is to call the aliasing layer's bypass routine.
|
|
|
|
This method is most suitable when you wish to invoke the operation
|
2002-10-01 17:40:23 +04:00
|
|
|
currently being handled on the lower layer.
|
|
|
|
It has the advantage that the bypass routine already must do argument mapping.
|
2001-11-16 13:25:42 +03:00
|
|
|
An example of this is
|
1994-06-08 23:23:02 +04:00
|
|
|
.Em null_getattrs
|
|
|
|
in the null layer.
|
|
|
|
.Pp
|
2001-06-07 17:58:23 +04:00
|
|
|
A second approach is to directly invoke vnode operations on
|
1994-06-08 23:23:02 +04:00
|
|
|
the lower layer with the
|
|
|
|
.Em VOP_OPERATIONNAME
|
|
|
|
interface.
|
|
|
|
The advantage of this method is that it is easy to invoke
|
2002-10-01 17:40:23 +04:00
|
|
|
arbitrary operations on the lower layer.
|
|
|
|
The disadvantage is that vnode arguments must be manually mapped.
|
1994-06-08 23:23:02 +04:00
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr mount 8
|
2004-06-10 18:13:36 +04:00
|
|
|
.Pp
|
1994-06-08 23:23:02 +04:00
|
|
|
UCLA Technical Report CSD-910056,
|
|
|
|
.Em "Stackable Layers: an Architecture for File System Development" .
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
1997-09-15 09:35:37 +04:00
|
|
|
.Nm
|
1998-02-06 08:54:12 +03:00
|
|
|
utility first appeared in
|
|
|
|
.Bx 4.4 .
|