2 .\" Copyright (c) 1992, 1993, 1994
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software donated to Berkeley by
6 .\" 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 file system sub-tree; demonstrate the use of a null file system layer"
51 null layer, duplicating a sub-tree of the file system
52 name space under another part of the global file system namespace.
53 This allows existing files and directories to be accessed
54 using a different pathname.
56 The primary differences between a virtual copy of the file system
57 and a symbolic link are that the
59 functions work correctly in the virtual copy, and that other file systems
60 may be mounted on the virtual copy without affecting the original.
61 A different device number for the virtual copy is returned by
63 but in other respects it is indistinguishable from the original.
67 utility supports mounting both directories and single files.
72 must be the same type.
73 Mounting directories to files or files to
74 directories is not supported.
78 file system differs from a traditional
79 loopback file system in two respects: it is implemented using
80 a stackable layers techniques, and its
83 all lower-layer vnodes, not just over directory vnodes.
85 The options are as follows:
86 .Bl -tag -width indent
88 Options are specified with a
90 flag followed by a comma separated string of options.
93 man page for possible options and their meanings.
94 Additionally the following option is supported:
95 .Bl -tag -width indent
97 Disable metadata caching in the null layer.
98 Some lower-layer file systems may force this option.
99 Depending on the access pattern,
100 this may result in increased lock contention.
104 The null layer has two purposes.
105 First, it serves as a demonstration of layering by providing a layer
107 (It actually does everything the loopback file system does,
108 which is slightly more than nothing.)
109 Second, the null layer can serve as a prototype layer.
110 Since it provides all necessary layer framework,
111 new file system layers can be created very easily by starting
114 The remainder of this man page examines the null layer as a basis
115 for constructing new layers.
118 .Sh INSTANTIATING NEW NULL LAYERS
119 New null layers are created with
123 utility takes two arguments, the pathname
124 of the lower vfs (target-pn) and the pathname where the null
125 layer will appear in the namespace (mount-point-pn).
127 the null layer is put into place, the contents
128 of target-pn subtree will be aliased under mount-point-pn.
131 .Sh OPERATION OF A NULL LAYER
132 The null layer is the minimum file system layer,
133 simply bypassing all possible operations to the lower layer
134 for processing there.
135 The majority of its activity centers
136 on the bypass routine, through which nearly all vnode operations
139 The bypass routine accepts arbitrary vnode operations for
140 handling by the lower layer.
141 It begins by examining vnode
142 operation arguments and replacing any null-nodes by their
143 lower-layer equivalents.
144 It then invokes the operation
146 Finally, it replaces the null-nodes
147 in the arguments and, if a vnode is returned by the operation,
148 stacks a null-node on top of the returned vnode.
150 Although bypass handles most operations,
158 must change the fsid being returned.
162 are not bypassed so that
163 they can handle freeing null-layer specific data.
165 is not bypassed to avoid excessive debugging
169 .Sh INSTANTIATING VNODE STACKS
170 Mounting associates the null layer with a lower layer,
171 in effect stacking two VFSes.
172 Vnode stacks are instead
173 created on demand as files are accessed.
175 The initial mount creates a single vnode stack for the
176 root of the new null layer.
177 All other vnode stacks
178 are created as a result of vnode operations on
179 this or other null vnode stacks.
181 New vnode stacks come into existence as a result of
182 an operation which returns a vnode.
183 The bypass routine stacks a null-node above the new
184 vnode before returning it to the caller.
186 For example, imagine mounting a null layer with
187 .Bd -literal -offset indent
188 mount_nullfs /usr/include /dev/layer/null
191 Changing directory to
194 the root null-node (which was created when the null layer was mounted).
197 A vop_lookup would be
198 done on the root null-node.
199 This operation would bypass through
200 to the lower layer which would return a vnode representing
203 Null_bypass then builds a null-node
206 and returns this to the caller.
207 Later operations on the null-node
210 process when constructing other vnode stacks.
213 .Sh CREATING OTHER FILE SYSTEM LAYERS
214 One of the easiest ways to construct new file system layers is to make
215 a copy of the null layer, rename all files and variables, and
216 then begin modifying the copy.
219 utility can be used to easily rename
222 The umap layer is an example of a layer descended from the
226 .Sh INVOKING OPERATIONS ON LOWER LAYERS
227 There are two techniques to invoke operations on a lower layer
228 when the operation cannot be completely bypassed.
230 is appropriate in different situations.
232 it is the responsibility of the aliasing layer to make
233 the operation arguments "correct" for the lower layer
234 by mapping a vnode argument to the lower layer.
236 The first approach is to call the aliasing layer's bypass routine.
237 This method is most suitable when you wish to invoke the operation
238 currently being handled on the lower layer.
239 It has the advantage that
240 the bypass routine already must do argument mapping.
241 An example of this is
245 A second approach is to directly invoke vnode operations on
246 the lower layer with the
247 .Em VOP_OPERATIONNAME
249 The advantage of this method is that it is easy to invoke
250 arbitrary operations on the lower layer.
252 is that vnode arguments must be manually mapped.
258 UCLA Technical Report CSD-910056,
259 .Em "Stackable Layers: an Architecture for File System Development" .
263 utility first appeared in