1994-05-26 08:35:07 +02: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.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" 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-03-11 13:40:45 +01:00
|
|
|
.\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95
|
1999-08-28 02:22:10 +02:00
|
|
|
.\" $FreeBSD$
|
1994-05-26 08:35:07 +02:00
|
|
|
.\"
|
1997-03-11 13:40:45 +01:00
|
|
|
.Dd May 1, 1995
|
2001-05-23 16:58:19 +02:00
|
|
|
.Dt MOUNT_NULLFS 8
|
|
|
|
.Os
|
1994-05-26 08:35:07 +02:00
|
|
|
.Sh NAME
|
2001-05-23 16:58:19 +02:00
|
|
|
.Nm mount_nullfs
|
2002-08-21 20:11:48 +02:00
|
|
|
.Nd "mount a loopback file system sub-tree; demonstrate the use of a null file system layer"
|
1994-05-26 08:35:07 +02:00
|
|
|
.Sh SYNOPSIS
|
2000-11-20 17:52:27 +01:00
|
|
|
.Nm
|
1994-05-26 08:35:07 +02:00
|
|
|
.Op Fl o Ar options
|
|
|
|
.Ar target
|
|
|
|
.Ar mount-point
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
1998-07-06 09:17:27 +02:00
|
|
|
.Nm
|
2002-07-06 21:34:18 +02:00
|
|
|
utility creates a
|
2002-08-21 20:11:48 +02:00
|
|
|
null layer, duplicating a sub-tree of the file system
|
|
|
|
name space under another part of the global file system namespace.
|
1997-03-11 13:40:45 +01:00
|
|
|
This allows existing files and directories to be accessed
|
|
|
|
using a different pathname.
|
|
|
|
.Pp
|
2002-08-21 20:11:48 +02:00
|
|
|
The primary differences between a virtual copy of the file system
|
2001-07-02 00:47:09 +02:00
|
|
|
and a symbolic link are that the
|
1997-03-11 13:40:45 +01:00
|
|
|
.Xr getcwd 3
|
2002-08-21 20:11:48 +02:00
|
|
|
functions work correctly in the virtual copy, and that other file systems
|
1997-03-11 13:40:45 +01:00
|
|
|
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
|
1998-07-06 09:17:27 +02:00
|
|
|
.Nm
|
2002-08-21 20:11:48 +02:00
|
|
|
file system differs from a traditional
|
|
|
|
loopback file system in two respects: it is implemented using
|
2004-01-08 00:31:22 +01:00
|
|
|
a stackable layers techniques, and its
|
2000-12-27 15:40:52 +01:00
|
|
|
.Do null-node Dc Ns s
|
1994-05-26 08:35:07 +02:00
|
|
|
stack above
|
|
|
|
all lower-layer vnodes, not just over directory vnodes.
|
|
|
|
.Pp
|
|
|
|
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.
|
1994-10-30 19:23:22 +01:00
|
|
|
First, it serves as a demonstration of layering by providing a layer
|
1994-05-26 08:35:07 +02:00
|
|
|
which does nothing.
|
2002-08-21 20:11:48 +02:00
|
|
|
(It actually does everything the loopback file system does,
|
1994-05-26 08:35:07 +02:00
|
|
|
which is slightly more than nothing.)
|
|
|
|
Second, the null layer can serve as a prototype layer.
|
|
|
|
Since it provides all necessary layer framework,
|
2002-08-21 20:11:48 +02:00
|
|
|
new file system layers can be created very easily by starting
|
1994-05-26 08:35:07 +02: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-07-15 09:53:42 +02:00
|
|
|
New null layers are created with
|
2001-05-23 16:58:19 +02:00
|
|
|
.Nm .
|
2002-07-06 21:34:18 +02:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility takes two arguments, the pathname
|
1994-05-26 08:35:07 +02:00
|
|
|
of the lower vfs (target-pn) and the pathname where the null
|
2004-07-02 23:45:06 +02:00
|
|
|
layer will appear in the namespace (mount-point-pn).
|
|
|
|
After
|
1994-05-26 08:35:07 +02:00
|
|
|
the null layer is put into place, the contents
|
|
|
|
of target-pn subtree will be aliased under mount-point-pn.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh OPERATION OF A NULL LAYER
|
2002-08-21 20:11:48 +02:00
|
|
|
The null layer is the minimum file system layer,
|
1994-05-26 08:35:07 +02:00
|
|
|
simply bypassing all possible operations to the lower layer
|
2004-07-02 23:45:06 +02:00
|
|
|
for processing there.
|
|
|
|
The majority of its activity centers
|
2000-05-15 16:55:56 +02:00
|
|
|
on the bypass routine, through which nearly all vnode operations
|
1994-05-26 08:35:07 +02:00
|
|
|
pass.
|
|
|
|
.Pp
|
|
|
|
The bypass routine accepts arbitrary vnode operations for
|
2004-07-02 23:45:06 +02:00
|
|
|
handling by the lower layer.
|
|
|
|
It begins by examining vnode
|
1994-05-26 08:35:07 +02:00
|
|
|
operation arguments and replacing any null-nodes by their
|
2004-07-02 23:45:06 +02:00
|
|
|
lower-layer equivalents.
|
|
|
|
It then invokes the operation
|
|
|
|
on the lower layer.
|
|
|
|
Finally, it replaces the null-nodes
|
1994-05-26 08:35:07 +02: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-07-15 09:53:42 +02:00
|
|
|
Although bypass handles most operations,
|
|
|
|
.Em vop_getattr ,
|
1994-05-26 08:35:07 +02:00
|
|
|
.Em vop_inactive ,
|
|
|
|
.Em vop_reclaim ,
|
|
|
|
and
|
|
|
|
.Em vop_print
|
|
|
|
are not bypassed.
|
|
|
|
.Em Vop_getattr
|
|
|
|
must change the fsid being returned.
|
|
|
|
.Em Vop_inactive
|
2000-05-15 16:55:56 +02:00
|
|
|
and
|
|
|
|
.Em vop_reclaim
|
|
|
|
are not bypassed so that
|
1994-05-26 08:35:07 +02:00
|
|
|
they can handle freeing null-layer specific data.
|
|
|
|
.Em Vop_print
|
|
|
|
is not bypassed to avoid excessive debugging
|
|
|
|
information.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh INSTANTIATING VNODE STACKS
|
|
|
|
Mounting associates the null layer with a lower layer,
|
2004-07-02 23:45:06 +02:00
|
|
|
in effect stacking two VFSes.
|
|
|
|
Vnode stacks are instead
|
1994-05-26 08:35:07 +02:00
|
|
|
created on demand as files are accessed.
|
|
|
|
.Pp
|
|
|
|
The initial mount creates a single vnode stack for the
|
2004-07-02 23:45:06 +02:00
|
|
|
root of the new null layer.
|
|
|
|
All other vnode stacks
|
1994-05-26 08:35:07 +02: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-07-15 09:53:42 +02:00
|
|
|
an operation which returns a vnode.
|
1994-05-26 08:35:07 +02: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
|
2001-05-23 16:58:19 +02:00
|
|
|
mount_nullfs /usr/include /dev/layer/null
|
1994-05-26 08:35:07 +02:00
|
|
|
.Ed
|
2006-04-19 21:21:42 +02:00
|
|
|
.Pp
|
2001-07-15 09:53:42 +02:00
|
|
|
Changing directory to
|
1994-05-26 08:35:07 +02:00
|
|
|
.Pa /dev/layer/null
|
|
|
|
will assign
|
|
|
|
the root null-node (which was created when the null layer was mounted).
|
2001-07-15 09:53:42 +02:00
|
|
|
Now consider opening
|
1994-05-26 08:35:07 +02:00
|
|
|
.Pa sys .
|
|
|
|
A vop_lookup would be
|
2004-07-02 23:45:06 +02:00
|
|
|
done on the root null-node.
|
|
|
|
This operation would bypass through
|
2001-07-15 09:53:42 +02:00
|
|
|
to the lower layer which would return a vnode representing
|
|
|
|
the UFS
|
1994-05-26 08:35:07 +02:00
|
|
|
.Pa sys .
|
|
|
|
Null_bypass then builds a null-node
|
2001-07-15 09:53:42 +02:00
|
|
|
aliasing the UFS
|
1994-05-26 08:35:07 +02:00
|
|
|
.Pa sys
|
|
|
|
and returns this to the caller.
|
2001-07-15 09:53:42 +02:00
|
|
|
Later operations on the null-node
|
1994-05-26 08:35:07 +02:00
|
|
|
.Pa sys
|
2001-07-15 09:53:42 +02:00
|
|
|
will repeat this
|
1994-05-26 08:35:07 +02:00
|
|
|
process when constructing other vnode stacks.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh CREATING OTHER FILE SYSTEM LAYERS
|
2002-08-21 20:11:48 +02:00
|
|
|
One of the easiest ways to construct new file system layers is to make
|
1994-05-26 08:35:07 +02:00
|
|
|
a copy of the null layer, rename all files and variables, and
|
1998-07-06 09:17:27 +02:00
|
|
|
then begin modifying the copy.
|
2003-02-05 14:50:41 +01:00
|
|
|
The
|
|
|
|
.Xr sed 1
|
|
|
|
utility can be used to easily rename
|
1994-05-26 08:35:07 +02:00
|
|
|
all variables.
|
|
|
|
.Pp
|
2001-07-15 09:53:42 +02:00
|
|
|
The umap layer is an example of a layer descended from the
|
1994-05-26 08:35:07 +02:00
|
|
|
null layer.
|
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh INVOKING OPERATIONS ON LOWER LAYERS
|
2001-07-15 09:53:42 +02:00
|
|
|
There are two techniques to invoke operations on a lower layer
|
2004-07-02 23:45:06 +02:00
|
|
|
when the operation cannot be completely bypassed.
|
|
|
|
Each method
|
|
|
|
is appropriate in different situations.
|
|
|
|
In both cases,
|
1994-05-26 08:35:07 +02:00
|
|
|
it is the responsibility of the aliasing layer to make
|
|
|
|
the operation arguments "correct" for the lower layer
|
2000-05-15 16:55:56 +02:00
|
|
|
by mapping a vnode argument to the lower layer.
|
1994-05-26 08:35:07 +02: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
|
2000-05-15 16:55:56 +02:00
|
|
|
currently being handled on the lower layer.
|
|
|
|
It has the advantage that
|
1996-10-06 00:27:30 +02:00
|
|
|
the bypass routine already must do argument mapping.
|
2001-07-15 09:53:42 +02:00
|
|
|
An example of this is
|
1994-05-26 08:35:07 +02:00
|
|
|
.Em null_getattrs
|
|
|
|
in the null layer.
|
|
|
|
.Pp
|
2000-05-15 16:55:56 +02:00
|
|
|
A second approach is to directly invoke vnode operations on
|
1994-05-26 08:35:07 +02:00
|
|
|
the lower layer with the
|
|
|
|
.Em VOP_OPERATIONNAME
|
|
|
|
interface.
|
|
|
|
The advantage of this method is that it is easy to invoke
|
2004-07-02 23:45:06 +02:00
|
|
|
arbitrary operations on the lower layer.
|
|
|
|
The disadvantage
|
2000-05-15 16:55:56 +02:00
|
|
|
is that vnode arguments must be manually mapped.
|
1994-05-26 08:35:07 +02:00
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr mount 8
|
2000-11-10 18:46:15 +01:00
|
|
|
.Pp
|
1994-05-26 08:35:07 +02:00
|
|
|
UCLA Technical Report CSD-910056,
|
|
|
|
.Em "Stackable Layers: an Architecture for File System Development" .
|
2005-01-18 11:09:38 +01:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility first appeared in
|
|
|
|
.Bx 4.4 .
|