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.4 (Berkeley) 4/19/94 38.\" 39.\" 40.Dd April 19, 1994 41.Dt MOUNT_NULL 8 42.Os BSD 4.4 43.Sh NAME 44.Nm mount_null 45.Nd demonstrate the use of a null file system layer 46.Sh SYNOPSIS 47.Nm mount_null 48.Op Fl o Ar options 49.Ar target 50.Ar mount-point 51.Sh DESCRIPTION 52The 53.Nm mount_null 54command creates a 55null layer, duplicating a sub-tree of the file system 56name space under another part of the global file system namespace. 57In this respect, it is 58similar to the loopback file system (see 59.Xr mount_lofs 8 ) . 60It differs from 61the loopback file system in two respects: it is implemented using 62a stackable layers techniques, and it's 63.Do 64null-node 65.Dc s 66stack above 67all lower-layer vnodes, not just over directory vnodes. 68.Pp 69The options are as follows: 70.Bl -tag -width indent 71.It Fl o 72Options are specified with a 73.Fl o 74flag followed by a comma separated string of options. 75See the 76.Xr mount 8 77man page for possible options and their meanings. 78.El 79.Pp 80The null layer has two purposes. 81First, it serves as a demonstration of layering by proving a layer 82which does nothing. 83(It actually does everything the loopback file system does, 84which is slightly more than nothing.) 85Second, the null layer can serve as a prototype layer. 86Since it provides all necessary layer framework, 87new file system layers can be created very easily be starting 88with a null layer. 89.Pp 90The remainder of this man page examines the null layer as a basis 91for constructing new layers. 92.\" 93.\" 94.Sh INSTANTIATING NEW NULL LAYERS 95New null layers are created with 96.Xr mount_null 8 . 97.Xr Mount_null 8 98takes two arguments, the pathname 99of the lower vfs (target-pn) and the pathname where the null 100layer will appear in the namespace (mount-point-pn). After 101the null layer is put into place, the contents 102of target-pn subtree will be aliased under mount-point-pn. 103.\" 104.\" 105.Sh OPERATION OF A NULL LAYER 106The null layer is the minimum file system layer, 107simply bypassing all possible operations to the lower layer 108for processing there. The majority of its activity centers 109on the bypass routine, though which nearly all vnode operations 110pass. 111.Pp 112The bypass routine accepts arbitrary vnode operations for 113handling by the lower layer. It begins by examing vnode 114operation arguments and replacing any null-nodes by their 115lower-layer equivalents. It then invokes the operation 116on the lower layer. Finally, it replaces the null-nodes 117in the arguments and, if a vnode is returned by the operation, 118stacks a null-node on top of the returned vnode. 119.Pp 120Although bypass handles most operations, 121.Em vop_getattr , 122.Em vop_inactive , 123.Em vop_reclaim , 124and 125.Em vop_print 126are not bypassed. 127.Em Vop_getattr 128must change the fsid being returned. 129.Em Vop_inactive 130and vop_reclaim are not bypassed so that 131they can handle freeing null-layer specific data. 132.Em Vop_print 133is not bypassed to avoid excessive debugging 134information. 135.\" 136.\" 137.Sh INSTANTIATING VNODE STACKS 138Mounting associates the null layer with a lower layer, 139in effect stacking two VFSes. Vnode stacks are instead 140created on demand as files are accessed. 141.Pp 142The initial mount creates a single vnode stack for the 143root of the new null layer. All other vnode stacks 144are created as a result of vnode operations on 145this or other null vnode stacks. 146.Pp 147New vnode stacks come into existence as a result of 148an operation which returns a vnode. 149The bypass routine stacks a null-node above the new 150vnode before returning it to the caller. 151.Pp 152For example, imagine mounting a null layer with 153.Bd -literal -offset indent 154mount_null /usr/include /dev/layer/null 155.Ed 156Changing directory to 157.Pa /dev/layer/null 158will assign 159the root null-node (which was created when the null layer was mounted). 160Now consider opening 161.Pa sys . 162A vop_lookup would be 163done on the root null-node. This operation would bypass through 164to the lower layer which would return a vnode representing 165the UFS 166.Pa sys . 167Null_bypass then builds a null-node 168aliasing the UFS 169.Pa sys 170and returns this to the caller. 171Later operations on the null-node 172.Pa sys 173will repeat this 174process when constructing other vnode stacks. 175.\" 176.\" 177.Sh CREATING OTHER FILE SYSTEM LAYERS 178One of the easiest ways to construct new file system layers is to make 179a copy of the null layer, rename all files and variables, and 180then begin modifyng the copy. Sed can be used to easily rename 181all variables. 182.Pp 183The umap layer is an example of a layer descended from the 184null layer. 185.\" 186.\" 187.Sh INVOKING OPERATIONS ON LOWER LAYERS 188There are two techniques to invoke operations on a lower layer 189when the operation cannot be completely bypassed. Each method 190is appropriate in different situations. In both cases, 191it is the responsibility of the aliasing layer to make 192the operation arguments "correct" for the lower layer 193by mapping an vnode arguments to the lower layer. 194.Pp 195The first approach is to call the aliasing layer's bypass routine. 196This method is most suitable when you wish to invoke the operation 197currently being handled on the lower layer. It has the advantage 198the the bypass routine already must do argument mapping. 199An example of this is 200.Em null_getattrs 201in the null layer. 202.Pp 203A second approach is to directly invoked vnode operations on 204the lower layer with the 205.Em VOP_OPERATIONNAME 206interface. 207The advantage of this method is that it is easy to invoke 208arbitrary operations on the lower layer. The disadvantage 209is that vnodes arguments must be manually mapped. 210.\" 211.\" 212.Sh SEE ALSO 213.Xr mount 8 214.sp 215UCLA Technical Report CSD-910056, 216.Em "Stackable Layers: an Architecture for File System Development" . 217.Sh HISTORY 218The 219.Nm mount_null 220utility first appeared in 4.4BSD. 221