1 .\" $NetBSD: mount_null.8,v 1.20 2004/06/10 14:13:36 uebayasi Exp $
3 .\" Copyright (c) 1992, 1993, 1994
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software donated to Berkeley by
7 .\" John Heidemann of the UCLA Ficus project.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
18 .\" may be used to endorse or promote products derived from this software
19 .\" without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95
41 .Nd mount a loopback filesystem sub-tree;
42 demonstrate the use of a null file system layer
52 null layer, duplicating a sub-tree of the file system
53 name space under another part of the global file system namespace.
54 This allows existing files and directories to be accessed
55 using a different pathname.
57 The primary differences between a virtual copy of the filesystem
58 and a symbolic link are that
60 functions correctly in the virtual copy, and that other filesystems
61 may be mounted on the virtual copy without affecting the original.
62 A different device number for the virtual copy is returned by
64 but in other respects it is indistinguishable from the original.
68 filesystem differs from a traditional
69 loopback file system in two respects: it is implemented using
70 a stackable layers technique, and its
75 all lower-layer vnodes (not just above directory vnodes).
81 are converted to absolute paths before use.
83 The options are as follows:
84 .Bl -tag -width indent
86 Options are specified with a
88 flag followed by a comma separated string of options.
91 man page for possible options and their meanings.
94 The null layer has two purposes.
95 First, it serves as a demonstration of layering by providing a layer
97 Second, the null layer can serve as a prototype layer.
98 Since it provides all necessary layer framework,
99 new file system layers can be created very easily by starting
102 The remainder of this man page examines the null layer as a basis
103 for constructing new layers.
106 .Sh INSTANTIATING NEW NULL LAYERS
107 New null layers are created with
110 takes two arguments, the pathname
111 of the lower vfs (target-pn) and the pathname where the null
112 layer will appear in the namespace (mount-point-pn).
113 After the null layer is put into place, the contents
114 of target-pn subtree will be aliased under mount-point-pn.
117 .Sh OPERATION OF A NULL LAYER
118 The null layer is the minimum file system layer,
119 simply passing all possible operations to the lower layer
120 for processing there.
121 The majority of its activity centers on the bypass routine,
122 through which nearly all vnode operations pass.
124 The bypass routine accepts arbitrary vnode operations for
125 handling by the lower layer.
126 It begins by examining vnode operation arguments and replacing
127 any null-nodes by their lower-layer equivalents.
128 It then invokes the operation on the lower layer.
129 Finally, it replaces the null-nodes
130 in the arguments and, if a vnode is returned by the operation,
131 stacks a null-node on top of the returned vnode.
133 Although bypass handles most operations,
141 must change the fsid being returned.
143 and vop_reclaim are not bypassed so that
144 they can handle freeing null-layer specific data.
146 is not bypassed to avoid excessive debugging
150 .Sh INSTANTIATING VNODE STACKS
151 Mounting associates the null layer with a lower layer,
152 in effect stacking two VFSes.
153 Vnode stacks are instead
154 created on demand as files are accessed.
156 The initial mount creates a single vnode stack for the
157 root of the new null layer.
158 All other vnode stacks
159 are created as a result of vnode operations on
160 this or other null vnode stacks.
162 New vnode stacks come into existence as a result of
163 an operation which returns a vnode.
164 The bypass routine stacks a null-node above the new
165 vnode before returning it to the caller.
167 For example, imagine mounting a null layer with
168 .Bd -literal -offset indent
169 mount_null /usr/include /dev/layer/null
171 Changing directory to
174 the root null-node (which was created when the null layer was mounted).
177 A vop_lookup would be done on the root null-node.
178 This operation would bypass through to the lower layer
179 which would return a vnode representing the UFS
181 null_bypass then builds a null-node aliasing the UFS
183 and returns this to the caller.
184 Later operations on the null-node
186 will repeat this process when constructing other vnode stacks.
189 .Sh CREATING OTHER FILE SYSTEM LAYERS
190 One of the easiest ways to construct new file system layers is to make
191 a copy of the null layer, rename all files and variables, and
192 then begin modifying the copy.
194 can be used to easily rename all variables.
196 The umap layer is an example of a layer descended from the
200 .Sh INVOKING OPERATIONS ON LOWER LAYERS
201 There are two techniques to invoke operations on a lower layer
202 when the operation cannot be completely bypassed.
203 Each method is appropriate in different situations.
204 In both cases, it is the responsibility of the aliasing layer to make
205 the operation arguments "correct" for the lower layer
206 by mapping any vnode arguments to the lower layer.
208 The first approach is to call the aliasing layer's bypass routine.
209 This method is most suitable when you wish to invoke the operation
210 currently being handled on the lower layer.
211 It has the advantage that the bypass routine already must do argument mapping.
212 An example of this is
216 A second approach is to directly invoke vnode operations on
217 the lower layer with the
218 .Em VOP_OPERATIONNAME
220 The advantage of this method is that it is easy to invoke
221 arbitrary operations on the lower layer.
222 The disadvantage is that vnode arguments must be manually mapped.
228 UCLA Technical Report CSD-910056,
229 .Em "Stackable Layers: an Architecture for File System Development" .
233 utility first appeared in