154841Sheideman.\" 266473Sbostic.\" 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*69147Smckusick.\" @(#)mount_null.8 8.6 (Berkeley) 05/01/95 1254841Sheideman.\" 1354841Sheideman.\" 1454841Sheideman.Dd 1554841Sheideman.Dt MOUNT_NULL 8 1654841Sheideman.Os BSD 4.4 1754841Sheideman.Sh NAME 1854841Sheideman.Nm mount_null 19*69147Smckusick.Nd mount a loopback filesystem sub-tree; 20*69147Smckusickdemonstrate the use of a null file system layer 2154841Sheideman.Sh SYNOPSIS 2254841Sheideman.Nm mount_null 2366473Sbostic.Op Fl o Ar options 2466473Sbostic.Ar target 2566473Sbostic.Ar mount-point 2654841Sheideman.Sh DESCRIPTION 2754841SheidemanThe 2854841Sheideman.Nm mount_null 2954953Sheidemancommand creates a 3054953Sheidemannull layer, duplicating a sub-tree of the file system 3154953Sheidemanname space under another part of the global file system namespace. 3269146SmckusickThis allows existing files and directories to be accessed 3369146Smckusickusing a different pathname. 3469146Smckusick.Pp 3569146SmckusickThe primary differences between a virtual copy of the filesystem 3669146Smckusickand a symbolic link are that 3769146Smckusick.Xr getcwd 3 3869146Smckusickfunctions correctly in the virtual copy, and that other filesystems 3969146Smckusickmay be mounted on the virtual copy without affecting the original. 4069146SmckusickA different device number for the virtual copy is returned by 4169146Smckusick.Xr stat 2 , 4269146Smckusickbut in other respects it is indistinguishable from the original. 4369146Smckusick.Pp 4469146SmckusickThe 4569146Smckusick.Nm mount_null 4669146Smckusickfilesystem differs from a traditional 4769146Smckusickloopback file system in two respects: it is implemented using 4854953Sheidemana stackable layers techniques, and it's 4954953Sheideman.Do 5054953Sheidemannull-node 5154953Sheideman.Dc s 5254953Sheidemanstack above 5354953Sheidemanall lower-layer vnodes, not just over directory vnodes. 5454841Sheideman.Pp 5566473SbosticThe options are as follows: 5666473Sbostic.Bl -tag -width indent 5766473Sbostic.It Fl o 5866473SbosticOptions are specified with a 5966473Sbostic.Fl o 6066473Sbosticflag followed by a comma separated string of options. 6166473SbosticSee the 6266473Sbostic.Xr mount 8 6366473Sbosticman page for possible options and their meanings. 6466473Sbostic.El 6566473Sbostic.Pp 6666473SbosticThe null layer has two purposes. 6766473SbosticFirst, it serves as a demonstration of layering by proving a layer 6866473Sbosticwhich does nothing. 6966473Sbostic(It actually does everything the loopback file system does, 7066473Sbosticwhich is slightly more than nothing.) 7166473SbosticSecond, the null layer can serve as a prototype layer. 7266473SbosticSince it provides all necessary layer framework, 7354953Sheidemannew file system layers can be created very easily be starting 7454953Sheidemanwith a null layer. 7554841Sheideman.Pp 7654953SheidemanThe remainder of this man page examines the null layer as a basis 7754953Sheidemanfor constructing new layers. 7854953Sheideman.\" 7954953Sheideman.\" 8054953Sheideman.Sh INSTANTIATING NEW NULL LAYERS 8154953SheidemanNew null layers are created with 8254953Sheideman.Xr mount_null 8 . 8354953Sheideman.Xr Mount_null 8 8454953Sheidemantakes two arguments, the pathname 8554953Sheidemanof the lower vfs (target-pn) and the pathname where the null 8654953Sheidemanlayer will appear in the namespace (mount-point-pn). After 8754953Sheidemanthe null layer is put into place, the contents 8854953Sheidemanof target-pn subtree will be aliased under mount-point-pn. 8954953Sheideman.\" 9054953Sheideman.\" 9154953Sheideman.Sh OPERATION OF A NULL LAYER 9254953SheidemanThe null layer is the minimum file system layer, 9354953Sheidemansimply bypassing all possible operations to the lower layer 9454953Sheidemanfor processing there. The majority of its activity centers 9554953Sheidemanon the bypass routine, though which nearly all vnode operations 9654953Sheidemanpass. 9754953Sheideman.Pp 9854953SheidemanThe bypass routine accepts arbitrary vnode operations for 9954953Sheidemanhandling by the lower layer. It begins by examing vnode 10054953Sheidemanoperation arguments and replacing any null-nodes by their 10166991Sbosticlower-layer equivalents. It then invokes the operation 10254953Sheidemanon the lower layer. Finally, it replaces the null-nodes 10365103Smckusickin the arguments and, if a vnode is returned by the operation, 10454953Sheidemanstacks a null-node on top of the returned vnode. 10554953Sheideman.Pp 10654953SheidemanAlthough bypass handles most operations, 10754953Sheideman.Em vop_getattr , 10854953Sheideman.Em vop_inactive , 10954953Sheideman.Em vop_reclaim , 11054953Sheidemanand 11154953Sheideman.Em vop_print 11254953Sheidemanare not bypassed. 11354953Sheideman.Em Vop_getattr 11454953Sheidemanmust change the fsid being returned. 11554953Sheideman.Em Vop_inactive 11654953Sheidemanand vop_reclaim are not bypassed so that 11754953Sheidemanthey can handle freeing null-layer specific data. 11854953Sheideman.Em Vop_print 11954953Sheidemanis not bypassed to avoid excessive debugging 12054953Sheidemaninformation. 12154953Sheideman.\" 12254953Sheideman.\" 12354953Sheideman.Sh INSTANTIATING VNODE STACKS 12454953SheidemanMounting associates the null layer with a lower layer, 12554953Sheidemanin effect stacking two VFSes. Vnode stacks are instead 12654953Sheidemancreated on demand as files are accessed. 12754953Sheideman.Pp 12854953SheidemanThe initial mount creates a single vnode stack for the 12954953Sheidemanroot of the new null layer. All other vnode stacks 13054953Sheidemanare created as a result of vnode operations on 13154953Sheidemanthis or other null vnode stacks. 13254953Sheideman.Pp 13366991SbosticNew vnode stacks come into existence as a result of 13454953Sheidemanan operation which returns a vnode. 13554953SheidemanThe bypass routine stacks a null-node above the new 13654953Sheidemanvnode before returning it to the caller. 13754953Sheideman.Pp 13854953SheidemanFor example, imagine mounting a null layer with 13954953Sheideman.Bd -literal -offset indent 14054953Sheidemanmount_null /usr/include /dev/layer/null 14154953Sheideman.Ed 14266991SbosticChanging directory to 14354953Sheideman.Pa /dev/layer/null 14454953Sheidemanwill assign 14554953Sheidemanthe root null-node (which was created when the null layer was mounted). 14654953SheidemanNow consider opening 14754953Sheideman.Pa sys . 14854953SheidemanA vop_lookup would be 14954953Sheidemandone on the root null-node. This operation would bypass through 15054953Sheidemanto the lower layer which would return a vnode representing 15154953Sheidemanthe UFS 15254953Sheideman.Pa sys . 15354953SheidemanNull_bypass then builds a null-node 15454953Sheidemanaliasing the UFS 15554953Sheideman.Pa sys 15654953Sheidemanand returns this to the caller. 15754953SheidemanLater operations on the null-node 15854953Sheideman.Pa sys 15954953Sheidemanwill repeat this 16054953Sheidemanprocess when constructing other vnode stacks. 16154953Sheideman.\" 16254953Sheideman.\" 16354953Sheideman.Sh CREATING OTHER FILE SYSTEM LAYERS 16454953SheidemanOne of the easiest ways to construct new file system layers is to make 16554953Sheidemana copy of the null layer, rename all files and variables, and 16666991Sbosticthen begin modifyng the copy. Sed can be used to easily rename 16754953Sheidemanall variables. 16854953Sheideman.Pp 16954953SheidemanThe umap layer is an example of a layer descended from the 17054953Sheidemannull layer. 17154953Sheideman.\" 17254953Sheideman.\" 17354953Sheideman.Sh INVOKING OPERATIONS ON LOWER LAYERS 17454953SheidemanThere are two techniques to invoke operations on a lower layer 17554953Sheidemanwhen the operation cannot be completely bypassed. Each method 17654953Sheidemanis appropriate in different situations. In both cases, 17754953Sheidemanit is the responsibility of the aliasing layer to make 17854953Sheidemanthe operation arguments "correct" for the lower layer 17954953Sheidemanby mapping an vnode arguments to the lower layer. 18054953Sheideman.Pp 18154953SheidemanThe first approach is to call the aliasing layer's bypass routine. 18254953SheidemanThis method is most suitable when you wish to invoke the operation 18365103Smckusickcurrently being handled on the lower layer. It has the advantage 18454953Sheidemanthe the bypass routine already must do argument mapping. 18554953SheidemanAn example of this is 18654953Sheideman.Em null_getattrs 18754953Sheidemanin the null layer. 18854953Sheideman.Pp 18954953SheidemanA second approach is to directly invoked vnode operations on 19054953Sheidemanthe lower layer with the 19154953Sheideman.Em VOP_OPERATIONNAME 19254953Sheidemaninterface. 19354953SheidemanThe advantage of this method is that it is easy to invoke 19454953Sheidemanarbitrary operations on the lower layer. The disadvantage 19566991Sbosticis that vnodes arguments must be manually mapped. 19654953Sheideman.\" 19754953Sheideman.\" 19854953Sheideman.Sh SEE ALSO 19966473Sbostic.Xr mount 8 20066473Sbostic.sp 20154953SheidemanUCLA Technical Report CSD-910056, 20254953Sheideman.Em "Stackable Layers: an Architecture for File System Development" . 20354841Sheideman.Sh HISTORY 20454841SheidemanThe 20562954Sbostic.Nm mount_null 20662954Sbosticutility first appeared in 4.4BSD. 207