18fae3551SRodney W. Grimes.\" 28fae3551SRodney W. Grimes.\" Copyright (c) 1992, 1993, 1994 38fae3551SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 48fae3551SRodney W. Grimes.\" 58fae3551SRodney W. Grimes.\" This code is derived from software donated to Berkeley by 68fae3551SRodney W. Grimes.\" John Heidemann of the UCLA Ficus project. 78fae3551SRodney W. Grimes.\" 88fae3551SRodney W. Grimes.\" 98fae3551SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 108fae3551SRodney W. Grimes.\" modification, are permitted provided that the following conditions 118fae3551SRodney W. Grimes.\" are met: 128fae3551SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 138fae3551SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 148fae3551SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 158fae3551SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 168fae3551SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 178fae3551SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 188fae3551SRodney W. Grimes.\" must display the following acknowledgement: 198fae3551SRodney W. Grimes.\" This product includes software developed by the University of 208fae3551SRodney W. Grimes.\" California, Berkeley and its contributors. 218fae3551SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 228fae3551SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 238fae3551SRodney W. Grimes.\" without specific prior written permission. 248fae3551SRodney W. Grimes.\" 258fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 268fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 278fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 288fae3551SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 298fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 308fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 318fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 328fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 338fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 348fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 358fae3551SRodney W. Grimes.\" SUCH DAMAGE. 368fae3551SRodney W. Grimes.\" 374a4c5285SPeter Wemm.\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95 387f3dea24SPeter Wemm.\" $FreeBSD$ 398fae3551SRodney W. Grimes.\" 404a4c5285SPeter Wemm.Dd May 1, 1995 418fae3551SRodney W. Grimes.Dt MOUNT_NULL 8 428fae3551SRodney W. Grimes.Os BSD 4.4 438fae3551SRodney W. Grimes.Sh NAME 448fae3551SRodney W. Grimes.Nm mount_null 454a4c5285SPeter Wemm.Nd mount a loopback filesystem sub-tree; 464a4c5285SPeter Wemmdemonstrate the use of a null file system layer 478fae3551SRodney W. Grimes.Sh SYNOPSIS 487c7fb079SRuslan Ermilov.Nm 498fae3551SRodney W. Grimes.Op Fl o Ar options 508fae3551SRodney W. Grimes.Ar target 518fae3551SRodney W. Grimes.Ar mount-point 528fae3551SRodney W. Grimes.Sh DESCRIPTION 538fae3551SRodney W. GrimesThe 547b353f1aSPhilippe Charnier.Nm 558fae3551SRodney W. Grimescommand creates a 568fae3551SRodney W. Grimesnull layer, duplicating a sub-tree of the file system 578fae3551SRodney W. Grimesname space under another part of the global file system namespace. 584a4c5285SPeter WemmThis allows existing files and directories to be accessed 594a4c5285SPeter Wemmusing a different pathname. 604a4c5285SPeter Wemm.Pp 614a4c5285SPeter WemmThe primary differences between a virtual copy of the filesystem 624a4c5285SPeter Wemmand a symbolic link are that 634a4c5285SPeter Wemm.Xr getcwd 3 644a4c5285SPeter Wemmfunctions correctly in the virtual copy, and that other filesystems 654a4c5285SPeter Wemmmay be mounted on the virtual copy without affecting the original. 664a4c5285SPeter WemmA different device number for the virtual copy is returned by 674a4c5285SPeter Wemm.Xr stat 2 , 684a4c5285SPeter Wemmbut in other respects it is indistinguishable from the original. 694a4c5285SPeter Wemm.Pp 704a4c5285SPeter WemmThe 717b353f1aSPhilippe Charnier.Nm 724a4c5285SPeter Wemmfilesystem differs from a traditional 734a4c5285SPeter Wemmloopback file system in two respects: it is implemented using 748fae3551SRodney W. Grimesa stackable layers techniques, and it's 758fae3551SRodney W. Grimes.Do 768fae3551SRodney W. Grimesnull-node 778fae3551SRodney W. Grimes.Dc s 788fae3551SRodney W. Grimesstack above 798fae3551SRodney W. Grimesall lower-layer vnodes, not just over directory vnodes. 808fae3551SRodney W. Grimes.Pp 818fae3551SRodney W. GrimesThe options are as follows: 828fae3551SRodney W. Grimes.Bl -tag -width indent 838fae3551SRodney W. Grimes.It Fl o 848fae3551SRodney W. GrimesOptions are specified with a 858fae3551SRodney W. Grimes.Fl o 868fae3551SRodney W. Grimesflag followed by a comma separated string of options. 878fae3551SRodney W. GrimesSee the 888fae3551SRodney W. Grimes.Xr mount 8 898fae3551SRodney W. Grimesman page for possible options and their meanings. 908fae3551SRodney W. Grimes.El 918fae3551SRodney W. Grimes.Pp 928fae3551SRodney W. GrimesThe null layer has two purposes. 93b210d5f6SJoerg WunschFirst, it serves as a demonstration of layering by providing a layer 948fae3551SRodney W. Grimeswhich does nothing. 958fae3551SRodney W. Grimes(It actually does everything the loopback file system does, 968fae3551SRodney W. Grimeswhich is slightly more than nothing.) 978fae3551SRodney W. GrimesSecond, the null layer can serve as a prototype layer. 988fae3551SRodney W. GrimesSince it provides all necessary layer framework, 99f88b745fSTim Vanderhoeknew file system layers can be created very easily by starting 1008fae3551SRodney W. Grimeswith a null layer. 1018fae3551SRodney W. Grimes.Pp 1028fae3551SRodney W. GrimesThe remainder of this man page examines the null layer as a basis 1038fae3551SRodney W. Grimesfor constructing new layers. 1048fae3551SRodney W. Grimes.\" 1058fae3551SRodney W. Grimes.\" 1068fae3551SRodney W. Grimes.Sh INSTANTIATING NEW NULL LAYERS 1078fae3551SRodney W. GrimesNew null layers are created with 1088fae3551SRodney W. Grimes.Xr mount_null 8 . 1098fae3551SRodney W. Grimes.Xr Mount_null 8 1108fae3551SRodney W. Grimestakes two arguments, the pathname 1118fae3551SRodney W. Grimesof the lower vfs (target-pn) and the pathname where the null 1128fae3551SRodney W. Grimeslayer will appear in the namespace (mount-point-pn). After 1138fae3551SRodney W. Grimesthe null layer is put into place, the contents 1148fae3551SRodney W. Grimesof target-pn subtree will be aliased under mount-point-pn. 1158fae3551SRodney W. Grimes.\" 1168fae3551SRodney W. Grimes.\" 1178fae3551SRodney W. Grimes.Sh OPERATION OF A NULL LAYER 1188fae3551SRodney W. GrimesThe null layer is the minimum file system layer, 1198fae3551SRodney W. Grimessimply bypassing all possible operations to the lower layer 1208fae3551SRodney W. Grimesfor processing there. The majority of its activity centers 121f88b745fSTim Vanderhoekon the bypass routine, through which nearly all vnode operations 1228fae3551SRodney W. Grimespass. 1238fae3551SRodney W. Grimes.Pp 1248fae3551SRodney W. GrimesThe bypass routine accepts arbitrary vnode operations for 125e71057d8SMike Pritchardhandling by the lower layer. It begins by examining vnode 1268fae3551SRodney W. Grimesoperation arguments and replacing any null-nodes by their 1278fae3551SRodney W. Grimeslower-layer equivalents. It then invokes the operation 1288fae3551SRodney W. Grimeson the lower layer. Finally, it replaces the null-nodes 1298fae3551SRodney W. Grimesin the arguments and, if a vnode is returned by the operation, 1308fae3551SRodney W. Grimesstacks a null-node on top of the returned vnode. 1318fae3551SRodney W. Grimes.Pp 1328fae3551SRodney W. GrimesAlthough bypass handles most operations, 1338fae3551SRodney W. Grimes.Em vop_getattr , 1348fae3551SRodney W. Grimes.Em vop_inactive , 1358fae3551SRodney W. Grimes.Em vop_reclaim , 1368fae3551SRodney W. Grimesand 1378fae3551SRodney W. Grimes.Em vop_print 1388fae3551SRodney W. Grimesare not bypassed. 1398fae3551SRodney W. Grimes.Em Vop_getattr 1408fae3551SRodney W. Grimesmust change the fsid being returned. 1418fae3551SRodney W. Grimes.Em Vop_inactive 142f88b745fSTim Vanderhoekand 143f88b745fSTim Vanderhoek.Em vop_reclaim 144f88b745fSTim Vanderhoekare not bypassed so that 1458fae3551SRodney W. Grimesthey can handle freeing null-layer specific data. 1468fae3551SRodney W. Grimes.Em Vop_print 1478fae3551SRodney W. Grimesis not bypassed to avoid excessive debugging 1488fae3551SRodney W. Grimesinformation. 1498fae3551SRodney W. Grimes.\" 1508fae3551SRodney W. Grimes.\" 1518fae3551SRodney W. Grimes.Sh INSTANTIATING VNODE STACKS 1528fae3551SRodney W. GrimesMounting associates the null layer with a lower layer, 1538fae3551SRodney W. Grimesin effect stacking two VFSes. Vnode stacks are instead 1548fae3551SRodney W. Grimescreated on demand as files are accessed. 1558fae3551SRodney W. Grimes.Pp 1568fae3551SRodney W. GrimesThe initial mount creates a single vnode stack for the 1578fae3551SRodney W. Grimesroot of the new null layer. All other vnode stacks 1588fae3551SRodney W. Grimesare created as a result of vnode operations on 1598fae3551SRodney W. Grimesthis or other null vnode stacks. 1608fae3551SRodney W. Grimes.Pp 1618fae3551SRodney W. GrimesNew vnode stacks come into existence as a result of 1628fae3551SRodney W. Grimesan operation which returns a vnode. 1638fae3551SRodney W. GrimesThe bypass routine stacks a null-node above the new 1648fae3551SRodney W. Grimesvnode before returning it to the caller. 1658fae3551SRodney W. Grimes.Pp 1668fae3551SRodney W. GrimesFor example, imagine mounting a null layer with 1678fae3551SRodney W. Grimes.Bd -literal -offset indent 1688fae3551SRodney W. Grimesmount_null /usr/include /dev/layer/null 1698fae3551SRodney W. Grimes.Ed 1708fae3551SRodney W. GrimesChanging directory to 1718fae3551SRodney W. Grimes.Pa /dev/layer/null 1728fae3551SRodney W. Grimeswill assign 1738fae3551SRodney W. Grimesthe root null-node (which was created when the null layer was mounted). 1748fae3551SRodney W. GrimesNow consider opening 1758fae3551SRodney W. Grimes.Pa sys . 1768fae3551SRodney W. GrimesA vop_lookup would be 1778fae3551SRodney W. Grimesdone on the root null-node. This operation would bypass through 1788fae3551SRodney W. Grimesto the lower layer which would return a vnode representing 1798fae3551SRodney W. Grimesthe UFS 1808fae3551SRodney W. Grimes.Pa sys . 1818fae3551SRodney W. GrimesNull_bypass then builds a null-node 1828fae3551SRodney W. Grimesaliasing the UFS 1838fae3551SRodney W. Grimes.Pa sys 1848fae3551SRodney W. Grimesand returns this to the caller. 1858fae3551SRodney W. GrimesLater operations on the null-node 1868fae3551SRodney W. Grimes.Pa sys 1878fae3551SRodney W. Grimeswill repeat this 1888fae3551SRodney W. Grimesprocess when constructing other vnode stacks. 1898fae3551SRodney W. Grimes.\" 1908fae3551SRodney W. Grimes.\" 1918fae3551SRodney W. Grimes.Sh CREATING OTHER FILE SYSTEM LAYERS 1928fae3551SRodney W. GrimesOne of the easiest ways to construct new file system layers is to make 1938fae3551SRodney W. Grimesa copy of the null layer, rename all files and variables, and 1947b353f1aSPhilippe Charnierthen begin modifying the copy. 1957b353f1aSPhilippe Charnier.Xr Sed 1 1967b353f1aSPhilippe Charniercan be used to easily rename 1978fae3551SRodney W. Grimesall variables. 1988fae3551SRodney W. Grimes.Pp 1998fae3551SRodney W. GrimesThe umap layer is an example of a layer descended from the 2008fae3551SRodney W. Grimesnull layer. 2018fae3551SRodney W. Grimes.\" 2028fae3551SRodney W. Grimes.\" 2038fae3551SRodney W. Grimes.Sh INVOKING OPERATIONS ON LOWER LAYERS 2048fae3551SRodney W. GrimesThere are two techniques to invoke operations on a lower layer 2058fae3551SRodney W. Grimeswhen the operation cannot be completely bypassed. Each method 2068fae3551SRodney W. Grimesis appropriate in different situations. In both cases, 2078fae3551SRodney W. Grimesit is the responsibility of the aliasing layer to make 2088fae3551SRodney W. Grimesthe operation arguments "correct" for the lower layer 209f88b745fSTim Vanderhoekby mapping a vnode argument to the lower layer. 2108fae3551SRodney W. Grimes.Pp 2118fae3551SRodney W. GrimesThe first approach is to call the aliasing layer's bypass routine. 2128fae3551SRodney W. GrimesThis method is most suitable when you wish to invoke the operation 213f88b745fSTim Vanderhoekcurrently being handled on the lower layer. 214f88b745fSTim VanderhoekIt has the advantage that 215e83201b4SWolfram Schneiderthe bypass routine already must do argument mapping. 2168fae3551SRodney W. GrimesAn example of this is 2178fae3551SRodney W. Grimes.Em null_getattrs 2188fae3551SRodney W. Grimesin the null layer. 2198fae3551SRodney W. Grimes.Pp 220f88b745fSTim VanderhoekA second approach is to directly invoke vnode operations on 2218fae3551SRodney W. Grimesthe lower layer with the 2228fae3551SRodney W. Grimes.Em VOP_OPERATIONNAME 2238fae3551SRodney W. Grimesinterface. 2248fae3551SRodney W. GrimesThe advantage of this method is that it is easy to invoke 2258fae3551SRodney W. Grimesarbitrary operations on the lower layer. The disadvantage 226f88b745fSTim Vanderhoekis that vnode arguments must be manually mapped. 2278fae3551SRodney W. Grimes.\" 2288fae3551SRodney W. Grimes.\" 2298fae3551SRodney W. Grimes.Sh SEE ALSO 2308fae3551SRodney W. Grimes.Xr mount 8 231726b61abSRuslan Ermilov.Pp 2328fae3551SRodney W. GrimesUCLA Technical Report CSD-910056, 2338fae3551SRodney W. Grimes.Em "Stackable Layers: an Architecture for File System Development" . 234558408f9SJordan K. Hubbard.Sh BUGS 235558408f9SJordan K. Hubbard 236558408f9SJordan K. HubbardTHIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK) 237558408f9SJordan K. HubbardAND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR 238558408f9SJordan K. HubbardOWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET. 239558408f9SJordan K. Hubbard 240558408f9SJordan K. HubbardThis code also needs an owner in order to be less dangerous - serious 241558408f9SJordan K. Hubbardhackers can apply by sending mail to hackers@freebsd.org and announcing 242558408f9SJordan K. Hubbardtheir intent to take it over. 243558408f9SJordan K. Hubbard 2448fae3551SRodney W. Grimes.Sh HISTORY 2458fae3551SRodney W. GrimesThe 2467b353f1aSPhilippe Charnier.Nm 247c0b0bcf4SMike Pritchardutility first appeared in 248c0b0bcf4SMike Pritchard.Bx 4.4 . 249