xref: /freebsd/sbin/mount_nullfs/mount_nullfs.8 (revision 3047fefe49f57a673de8df152c199de12ec2c6d3)
1.\"
2.\" Copyright (c) 1992, 1993, 1994
3.\"	The Regents of the University of California.  All rights reserved.
4.\"
5.\" This code is derived from software donated to Berkeley by
6.\" John Heidemann of the UCLA Ficus project.
7.\"
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"	This product includes software developed by the University of
20.\"	California, Berkeley and its contributors.
21.\" 4. Neither the name of the University nor the names of its contributors
22.\"    may be used to endorse or promote products derived from this software
23.\"    without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35.\" SUCH DAMAGE.
36.\"
37.\"     @(#)mount_null.8	8.6 (Berkeley) 5/1/95
38.\" $FreeBSD$
39.\"
40.Dd May 1, 1995
41.Dt MOUNT_NULLFS 8
42.Os
43.Sh NAME
44.Nm mount_nullfs
45.Nd "mount a loopback file system sub-tree; demonstrate the use of a null file system layer"
46.Sh SYNOPSIS
47.Nm
48.Op Fl o Ar options
49.Ar target
50.Ar mount-point
51.Sh DESCRIPTION
52The
53.Nm
54utility creates a
55null layer, duplicating a sub-tree of the file system
56name space under another part of the global file system namespace.
57This allows existing files and directories to be accessed
58using a different pathname.
59.Pp
60The primary differences between a virtual copy of the file system
61and a symbolic link are that the
62.Xr getcwd 3
63functions work correctly in the virtual copy, and that other file systems
64may be mounted on the virtual copy without affecting the original.
65A different device number for the virtual copy is returned by
66.Xr stat 2 ,
67but in other respects it is indistinguishable from the original.
68.Pp
69The
70.Nm
71file system differs from a traditional
72loopback file system in two respects: it is implemented using
73a stackable layers techniques, and it's
74.Do null-node Dc Ns s
75stack above
76all lower-layer vnodes, not just over directory vnodes.
77.Pp
78The options are as follows:
79.Bl -tag -width indent
80.It Fl o
81Options are specified with a
82.Fl o
83flag followed by a comma separated string of options.
84See the
85.Xr mount 8
86man page for possible options and their meanings.
87.El
88.Pp
89The null layer has two purposes.
90First, it serves as a demonstration of layering by providing a layer
91which does nothing.
92(It actually does everything the loopback file system does,
93which is slightly more than nothing.)
94Second, the null layer can serve as a prototype layer.
95Since it provides all necessary layer framework,
96new file system layers can be created very easily by starting
97with a null layer.
98.Pp
99The remainder of this man page examines the null layer as a basis
100for constructing new layers.
101.\"
102.\"
103.Sh INSTANTIATING NEW NULL LAYERS
104New null layers are created with
105.Nm .
106The
107.Nm
108utility takes two arguments, the pathname
109of the lower vfs (target-pn) and the pathname where the null
110layer will appear in the namespace (mount-point-pn).  After
111the null layer is put into place, the contents
112of target-pn subtree will be aliased under mount-point-pn.
113.\"
114.\"
115.Sh OPERATION OF A NULL LAYER
116The null layer is the minimum file system layer,
117simply bypassing all possible operations to the lower layer
118for processing there.  The majority of its activity centers
119on the bypass routine, through which nearly all vnode operations
120pass.
121.Pp
122The bypass routine accepts arbitrary vnode operations for
123handling by the lower layer.  It begins by examining vnode
124operation arguments and replacing any null-nodes by their
125lower-layer equivalents.  It then invokes the operation
126on the lower layer.  Finally, it replaces the null-nodes
127in the arguments and, if a vnode is returned by the operation,
128stacks a null-node on top of the returned vnode.
129.Pp
130Although bypass handles most operations,
131.Em vop_getattr ,
132.Em vop_inactive ,
133.Em vop_reclaim ,
134and
135.Em vop_print
136are not bypassed.
137.Em Vop_getattr
138must change the fsid being returned.
139.Em Vop_inactive
140and
141.Em vop_reclaim
142are not bypassed so that
143they can handle freeing null-layer specific data.
144.Em Vop_print
145is not bypassed to avoid excessive debugging
146information.
147.\"
148.\"
149.Sh INSTANTIATING VNODE STACKS
150Mounting associates the null layer with a lower layer,
151in effect stacking two VFSes.  Vnode stacks are instead
152created on demand as files are accessed.
153.Pp
154The initial mount creates a single vnode stack for the
155root of the new null layer.  All other vnode stacks
156are created as a result of vnode operations on
157this or other null vnode stacks.
158.Pp
159New vnode stacks come into existence as a result of
160an operation which returns a vnode.
161The bypass routine stacks a null-node above the new
162vnode before returning it to the caller.
163.Pp
164For example, imagine mounting a null layer with
165.Bd -literal -offset indent
166mount_nullfs /usr/include /dev/layer/null
167.Ed
168Changing directory to
169.Pa /dev/layer/null
170will assign
171the root null-node (which was created when the null layer was mounted).
172Now consider opening
173.Pa sys .
174A vop_lookup would be
175done on the root null-node.  This operation would bypass through
176to the lower layer which would return a vnode representing
177the UFS
178.Pa sys .
179Null_bypass then builds a null-node
180aliasing the UFS
181.Pa sys
182and returns this to the caller.
183Later operations on the null-node
184.Pa sys
185will repeat this
186process when constructing other vnode stacks.
187.\"
188.\"
189.Sh CREATING OTHER FILE SYSTEM LAYERS
190One of the easiest ways to construct new file system layers is to make
191a copy of the null layer, rename all files and variables, and
192then begin modifying the copy.
193.Xr Sed 1
194can be used to easily rename
195all variables.
196.Pp
197The umap layer is an example of a layer descended from the
198null layer.
199.\"
200.\"
201.Sh INVOKING OPERATIONS ON LOWER LAYERS
202There are two techniques to invoke operations on a lower layer
203when the operation cannot be completely bypassed.  Each method
204is appropriate in different situations.  In both cases,
205it is the responsibility of the aliasing layer to make
206the operation arguments "correct" for the lower layer
207by mapping a vnode argument to the lower layer.
208.Pp
209The first approach is to call the aliasing layer's bypass routine.
210This method is most suitable when you wish to invoke the operation
211currently being handled on the lower layer.
212It has the advantage that
213the bypass routine already must do argument mapping.
214An example of this is
215.Em null_getattrs
216in the null layer.
217.Pp
218A second approach is to directly invoke vnode operations on
219the lower layer with the
220.Em VOP_OPERATIONNAME
221interface.
222The advantage of this method is that it is easy to invoke
223arbitrary operations on the lower layer.  The disadvantage
224is that vnode arguments must be manually mapped.
225.\"
226.\"
227.Sh SEE ALSO
228.Xr mount 8
229.Pp
230UCLA Technical Report CSD-910056,
231.Em "Stackable Layers: an Architecture for File System Development" .
232.Sh BUGS
233THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
234AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM.  USE AT YOUR
235OWN RISK.  BEWARE OF DOG.  SLIPPERY WHEN WET.
236.Pp
237This code also needs an owner in order to be less dangerous - serious
238hackers can apply by sending mail to
239.Aq hackers@FreeBSD.org
240and announcing
241their intent to take it over.
242.Sh HISTORY
243The
244.Nm
245utility first appeared in
246.Bx 4.4 .
247