154841Sheideman.\" 2*66473Sbostic.\" Copyright (c) 1992, 1993, 1994 362955Sbostic.\" The Regents of the University of California. All rights reserved. 454841Sheideman.\" 554841Sheideman.\" This code is derived from software donated to Berkeley by 654953Sheideman.\" John Heidemann of the UCLA Ficus project. 754841Sheideman.\" 854841Sheideman.\" 954841Sheideman.\" %sccs.include.redist.roff% 1054841Sheideman.\" 11*66473Sbostic.\" @(#)mount_null.8 8.3 (Berkeley) 03/27/94 1254841Sheideman.\" 1354841Sheideman.\" 1454841Sheideman.Dd 1554841Sheideman.Dt MOUNT_NULL 8 1654841Sheideman.Os BSD 4.4 1754841Sheideman.Sh NAME 1854841Sheideman.Nm mount_null 1954953Sheideman.Nd demonstrate the use of a null file system layer 2054841Sheideman.Sh SYNOPSIS 2154841Sheideman.Nm mount_null 22*66473Sbostic.Op Fl o Ar options 23*66473Sbostic.Ar target 24*66473Sbostic.Ar mount-point 2554841Sheideman.Sh DESCRIPTION 2654841SheidemanThe 2754841Sheideman.Nm mount_null 2854953Sheidemancommand creates a 2954953Sheidemannull layer, duplicating a sub-tree of the file system 3054953Sheidemanname space under another part of the global file system namespace. 3154953SheidemanIn this respect, it is 3254953Sheidemansimilar to the loopback file system (see 3354953Sheideman.Xr mount_lofs 8 ) . 3454953SheidemanIt differs from 35*66473Sbosticthe loopback file system in two respects: it is implemented using 3654953Sheidemana stackable layers techniques, and it's 3754953Sheideman.Do 3854953Sheidemannull-node 3954953Sheideman.Dc s 4054953Sheidemanstack above 4154953Sheidemanall lower-layer vnodes, not just over directory vnodes. 4254841Sheideman.Pp 43*66473SbosticThe options are as follows: 44*66473Sbostic.Bl -tag -width indent 45*66473Sbostic.It Fl o 46*66473SbosticOptions are specified with a 47*66473Sbostic.Fl o 48*66473Sbosticflag followed by a comma separated string of options. 49*66473SbosticSee the 50*66473Sbostic.Xr mount 8 51*66473Sbosticman page for possible options and their meanings. 52*66473Sbostic.El 53*66473Sbostic.Pp 54*66473SbosticThe null layer has two purposes. 55*66473SbosticFirst, it serves as a demonstration of layering by proving a layer 56*66473Sbosticwhich does nothing. 57*66473Sbostic(It actually does everything the loopback file system does, 58*66473Sbosticwhich is slightly more than nothing.) 59*66473SbosticSecond, the null layer can serve as a prototype layer. 60*66473SbosticSince it provides all necessary layer framework, 6154953Sheidemannew file system layers can be created very easily be starting 6254953Sheidemanwith a null layer. 6354841Sheideman.Pp 6454953SheidemanThe remainder of this man page examines the null layer as a basis 6554953Sheidemanfor constructing new layers. 6654953Sheideman.\" 6754953Sheideman.\" 6854953Sheideman.Sh INSTANTIATING NEW NULL LAYERS 6954953SheidemanNew null layers are created with 7054953Sheideman.Xr mount_null 8 . 7154953Sheideman.Xr Mount_null 8 7254953Sheidemantakes two arguments, the pathname 7354953Sheidemanof the lower vfs (target-pn) and the pathname where the null 7454953Sheidemanlayer will appear in the namespace (mount-point-pn). After 7554953Sheidemanthe null layer is put into place, the contents 7654953Sheidemanof target-pn subtree will be aliased under mount-point-pn. 7754953Sheideman.\" 7854953Sheideman.\" 7954953Sheideman.Sh OPERATION OF A NULL LAYER 8054953SheidemanThe null layer is the minimum file system layer, 8154953Sheidemansimply bypassing all possible operations to the lower layer 8254953Sheidemanfor processing there. The majority of its activity centers 8354953Sheidemanon the bypass routine, though which nearly all vnode operations 8454953Sheidemanpass. 8554953Sheideman.Pp 8654953SheidemanThe bypass routine accepts arbitrary vnode operations for 8754953Sheidemanhandling by the lower layer. It begins by examing vnode 8854953Sheidemanoperation arguments and replacing any null-nodes by their 8965103Smckusicklower-layer equivalants. It then invokes the operation 9054953Sheidemanon the lower layer. Finally, it replaces the null-nodes 9165103Smckusickin the arguments and, if a vnode is returned by the operation, 9254953Sheidemanstacks a null-node on top of the returned vnode. 9354953Sheideman.Pp 9454953SheidemanAlthough bypass handles most operations, 9554953Sheideman.Em vop_getattr , 9654953Sheideman.Em vop_inactive , 9754953Sheideman.Em vop_reclaim , 9854953Sheidemanand 9954953Sheideman.Em vop_print 10054953Sheidemanare not bypassed. 10154953Sheideman.Em Vop_getattr 10254953Sheidemanmust change the fsid being returned. 10354953Sheideman.Em Vop_inactive 10454953Sheidemanand vop_reclaim are not bypassed so that 10554953Sheidemanthey can handle freeing null-layer specific data. 10654953Sheideman.Em Vop_print 10754953Sheidemanis not bypassed to avoid excessive debugging 10854953Sheidemaninformation. 10954953Sheideman.\" 11054953Sheideman.\" 11154953Sheideman.Sh INSTANTIATING VNODE STACKS 11254953SheidemanMounting associates the null layer with a lower layer, 11354953Sheidemanin effect stacking two VFSes. Vnode stacks are instead 11454953Sheidemancreated on demand as files are accessed. 11554953Sheideman.Pp 11654953SheidemanThe initial mount creates a single vnode stack for the 11754953Sheidemanroot of the new null layer. All other vnode stacks 11854953Sheidemanare created as a result of vnode operations on 11954953Sheidemanthis or other null vnode stacks. 12054953Sheideman.Pp 12154953SheidemanNew vnode stacks come into existance as a result of 12254953Sheidemanan operation which returns a vnode. 12354953SheidemanThe bypass routine stacks a null-node above the new 12454953Sheidemanvnode before returning it to the caller. 12554953Sheideman.Pp 12654953SheidemanFor example, imagine mounting a null layer with 12754953Sheideman.Bd -literal -offset indent 12854953Sheidemanmount_null /usr/include /dev/layer/null 12954953Sheideman.Ed 13054953SheidemanChainging directory to 13154953Sheideman.Pa /dev/layer/null 13254953Sheidemanwill assign 13354953Sheidemanthe root null-node (which was created when the null layer was mounted). 13454953SheidemanNow consider opening 13554953Sheideman.Pa sys . 13654953SheidemanA vop_lookup would be 13754953Sheidemandone on the root null-node. This operation would bypass through 13854953Sheidemanto the lower layer which would return a vnode representing 13954953Sheidemanthe UFS 14054953Sheideman.Pa sys . 14154953SheidemanNull_bypass then builds a null-node 14254953Sheidemanaliasing the UFS 14354953Sheideman.Pa sys 14454953Sheidemanand returns this to the caller. 14554953SheidemanLater operations on the null-node 14654953Sheideman.Pa sys 14754953Sheidemanwill repeat this 14854953Sheidemanprocess when constructing other vnode stacks. 14954953Sheideman.\" 15054953Sheideman.\" 15154953Sheideman.Sh CREATING OTHER FILE SYSTEM LAYERS 15254953SheidemanOne of the easiest ways to construct new file system layers is to make 15354953Sheidemana copy of the null layer, rename all files and variables, and 15454953Sheidemanthen begin modifing the copy. Sed can be used to easily rename 15554953Sheidemanall variables. 15654953Sheideman.Pp 15754953SheidemanThe umap layer is an example of a layer descended from the 15854953Sheidemannull layer. 15954953Sheideman.\" 16054953Sheideman.\" 16154953Sheideman.Sh INVOKING OPERATIONS ON LOWER LAYERS 16254953SheidemanThere are two techniques to invoke operations on a lower layer 16354953Sheidemanwhen the operation cannot be completely bypassed. Each method 16454953Sheidemanis appropriate in different situations. In both cases, 16554953Sheidemanit is the responsibility of the aliasing layer to make 16654953Sheidemanthe operation arguments "correct" for the lower layer 16754953Sheidemanby mapping an vnode arguments to the lower layer. 16854953Sheideman.Pp 16954953SheidemanThe first approach is to call the aliasing layer's bypass routine. 17054953SheidemanThis method is most suitable when you wish to invoke the operation 17165103Smckusickcurrently being handled on the lower layer. It has the advantage 17254953Sheidemanthe the bypass routine already must do argument mapping. 17354953SheidemanAn example of this is 17454953Sheideman.Em null_getattrs 17554953Sheidemanin the null layer. 17654953Sheideman.Pp 17754953SheidemanA second approach is to directly invoked vnode operations on 17854953Sheidemanthe lower layer with the 17954953Sheideman.Em VOP_OPERATIONNAME 18054953Sheidemaninterface. 18154953SheidemanThe advantage of this method is that it is easy to invoke 18254953Sheidemanarbitrary operations on the lower layer. The disadvantage 18354953Sheidemanis that vnodes arguments must be manualy mapped. 18454953Sheideman.\" 18554953Sheideman.\" 18654953Sheideman.Sh SEE ALSO 187*66473Sbostic.Xr mount 8 188*66473Sbostic.sp 18954953SheidemanUCLA Technical Report CSD-910056, 19054953Sheideman.Em "Stackable Layers: an Architecture for File System Development" . 19154841Sheideman.Sh HISTORY 19254841SheidemanThe 19362954Sbostic.Nm mount_null 19462954Sbosticutility first appeared in 4.4BSD. 195