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 416ad10804SRuslan Ermilov.Dt MOUNT_NULLFS 8 426ad10804SRuslan Ermilov.Os 438fae3551SRodney W. Grimes.Sh NAME 446ad10804SRuslan Ermilov.Nm mount_nullfs 45eb083802SRuslan Ermilov.Nd "mount a loopback filesystem sub-tree; demonstrate the use of a null file system layer" 468fae3551SRodney W. Grimes.Sh SYNOPSIS 477c7fb079SRuslan Ermilov.Nm 488fae3551SRodney W. Grimes.Op Fl o Ar options 498fae3551SRodney W. Grimes.Ar target 508fae3551SRodney W. Grimes.Ar mount-point 518fae3551SRodney W. Grimes.Sh DESCRIPTION 528fae3551SRodney W. GrimesThe 537b353f1aSPhilippe Charnier.Nm 548fae3551SRodney W. Grimescommand creates a 558fae3551SRodney W. Grimesnull layer, duplicating a sub-tree of the file system 568fae3551SRodney W. Grimesname space under another part of the global file system namespace. 574a4c5285SPeter WemmThis allows existing files and directories to be accessed 584a4c5285SPeter Wemmusing a different pathname. 594a4c5285SPeter Wemm.Pp 604a4c5285SPeter WemmThe primary differences between a virtual copy of the filesystem 617c9bebf9SDima Dorfmanand a symbolic link are that the 624a4c5285SPeter Wemm.Xr getcwd 3 637c9bebf9SDima Dorfmanfunctions work correctly in the virtual copy, and that other filesystems 644a4c5285SPeter Wemmmay be mounted on the virtual copy without affecting the original. 654a4c5285SPeter WemmA different device number for the virtual copy is returned by 664a4c5285SPeter Wemm.Xr stat 2 , 674a4c5285SPeter Wemmbut in other respects it is indistinguishable from the original. 684a4c5285SPeter Wemm.Pp 694a4c5285SPeter WemmThe 707b353f1aSPhilippe Charnier.Nm 714a4c5285SPeter Wemmfilesystem differs from a traditional 724a4c5285SPeter Wemmloopback file system in two respects: it is implemented using 738fae3551SRodney W. Grimesa stackable layers techniques, and it's 74d90d7015SRuslan Ermilov.Do null-node Dc Ns s 758fae3551SRodney W. Grimesstack above 768fae3551SRodney W. Grimesall lower-layer vnodes, not just over directory vnodes. 778fae3551SRodney W. Grimes.Pp 788fae3551SRodney W. GrimesThe options are as follows: 798fae3551SRodney W. Grimes.Bl -tag -width indent 808fae3551SRodney W. Grimes.It Fl o 818fae3551SRodney W. GrimesOptions are specified with a 828fae3551SRodney W. Grimes.Fl o 838fae3551SRodney W. Grimesflag followed by a comma separated string of options. 848fae3551SRodney W. GrimesSee the 858fae3551SRodney W. Grimes.Xr mount 8 868fae3551SRodney W. Grimesman page for possible options and their meanings. 878fae3551SRodney W. Grimes.El 888fae3551SRodney W. Grimes.Pp 898fae3551SRodney W. GrimesThe null layer has two purposes. 90b210d5f6SJoerg WunschFirst, it serves as a demonstration of layering by providing a layer 918fae3551SRodney W. Grimeswhich does nothing. 928fae3551SRodney W. Grimes(It actually does everything the loopback file system does, 938fae3551SRodney W. Grimeswhich is slightly more than nothing.) 948fae3551SRodney W. GrimesSecond, the null layer can serve as a prototype layer. 958fae3551SRodney W. GrimesSince it provides all necessary layer framework, 96f88b745fSTim Vanderhoeknew file system layers can be created very easily by starting 978fae3551SRodney W. Grimeswith a null layer. 988fae3551SRodney W. Grimes.Pp 998fae3551SRodney W. GrimesThe remainder of this man page examines the null layer as a basis 1008fae3551SRodney W. Grimesfor constructing new layers. 1018fae3551SRodney W. Grimes.\" 1028fae3551SRodney W. Grimes.\" 1038fae3551SRodney W. Grimes.Sh INSTANTIATING NEW NULL LAYERS 1048fae3551SRodney W. GrimesNew null layers are created with 1056ad10804SRuslan Ermilov.Nm . 1066ad10804SRuslan Ermilov.Nm Mount_nullfs 1078fae3551SRodney W. Grimestakes two arguments, the pathname 1088fae3551SRodney W. Grimesof the lower vfs (target-pn) and the pathname where the null 1098fae3551SRodney W. Grimeslayer will appear in the namespace (mount-point-pn). After 1108fae3551SRodney W. Grimesthe null layer is put into place, the contents 1118fae3551SRodney W. Grimesof target-pn subtree will be aliased under mount-point-pn. 1128fae3551SRodney W. Grimes.\" 1138fae3551SRodney W. Grimes.\" 1148fae3551SRodney W. Grimes.Sh OPERATION OF A NULL LAYER 1158fae3551SRodney W. GrimesThe null layer is the minimum file system layer, 1168fae3551SRodney W. Grimessimply bypassing all possible operations to the lower layer 1178fae3551SRodney W. Grimesfor processing there. The majority of its activity centers 118f88b745fSTim Vanderhoekon the bypass routine, through which nearly all vnode operations 1198fae3551SRodney W. Grimespass. 1208fae3551SRodney W. Grimes.Pp 1218fae3551SRodney W. GrimesThe bypass routine accepts arbitrary vnode operations for 122e71057d8SMike Pritchardhandling by the lower layer. It begins by examining vnode 1238fae3551SRodney W. Grimesoperation arguments and replacing any null-nodes by their 1248fae3551SRodney W. Grimeslower-layer equivalents. It then invokes the operation 1258fae3551SRodney W. Grimeson the lower layer. Finally, it replaces the null-nodes 1268fae3551SRodney W. Grimesin the arguments and, if a vnode is returned by the operation, 1278fae3551SRodney W. Grimesstacks a null-node on top of the returned vnode. 1288fae3551SRodney W. Grimes.Pp 1298fae3551SRodney W. GrimesAlthough bypass handles most operations, 1308fae3551SRodney W. Grimes.Em vop_getattr , 1318fae3551SRodney W. Grimes.Em vop_inactive , 1328fae3551SRodney W. Grimes.Em vop_reclaim , 1338fae3551SRodney W. Grimesand 1348fae3551SRodney W. Grimes.Em vop_print 1358fae3551SRodney W. Grimesare not bypassed. 1368fae3551SRodney W. Grimes.Em Vop_getattr 1378fae3551SRodney W. Grimesmust change the fsid being returned. 1388fae3551SRodney W. Grimes.Em Vop_inactive 139f88b745fSTim Vanderhoekand 140f88b745fSTim Vanderhoek.Em vop_reclaim 141f88b745fSTim Vanderhoekare not bypassed so that 1428fae3551SRodney W. Grimesthey can handle freeing null-layer specific data. 1438fae3551SRodney W. Grimes.Em Vop_print 1448fae3551SRodney W. Grimesis not bypassed to avoid excessive debugging 1458fae3551SRodney W. Grimesinformation. 1468fae3551SRodney W. Grimes.\" 1478fae3551SRodney W. Grimes.\" 1488fae3551SRodney W. Grimes.Sh INSTANTIATING VNODE STACKS 1498fae3551SRodney W. GrimesMounting associates the null layer with a lower layer, 1508fae3551SRodney W. Grimesin effect stacking two VFSes. Vnode stacks are instead 1518fae3551SRodney W. Grimescreated on demand as files are accessed. 1528fae3551SRodney W. Grimes.Pp 1538fae3551SRodney W. GrimesThe initial mount creates a single vnode stack for the 1548fae3551SRodney W. Grimesroot of the new null layer. All other vnode stacks 1558fae3551SRodney W. Grimesare created as a result of vnode operations on 1568fae3551SRodney W. Grimesthis or other null vnode stacks. 1578fae3551SRodney W. Grimes.Pp 1588fae3551SRodney W. GrimesNew vnode stacks come into existence as a result of 1598fae3551SRodney W. Grimesan operation which returns a vnode. 1608fae3551SRodney W. GrimesThe bypass routine stacks a null-node above the new 1618fae3551SRodney W. Grimesvnode before returning it to the caller. 1628fae3551SRodney W. Grimes.Pp 1638fae3551SRodney W. GrimesFor example, imagine mounting a null layer with 1648fae3551SRodney W. Grimes.Bd -literal -offset indent 1656ad10804SRuslan Ermilovmount_nullfs /usr/include /dev/layer/null 1668fae3551SRodney W. Grimes.Ed 1678fae3551SRodney W. GrimesChanging directory to 1688fae3551SRodney W. Grimes.Pa /dev/layer/null 1698fae3551SRodney W. Grimeswill assign 1708fae3551SRodney W. Grimesthe root null-node (which was created when the null layer was mounted). 1718fae3551SRodney W. GrimesNow consider opening 1728fae3551SRodney W. Grimes.Pa sys . 1738fae3551SRodney W. GrimesA vop_lookup would be 1748fae3551SRodney W. Grimesdone on the root null-node. This operation would bypass through 1758fae3551SRodney W. Grimesto the lower layer which would return a vnode representing 1768fae3551SRodney W. Grimesthe UFS 1778fae3551SRodney W. Grimes.Pa sys . 1788fae3551SRodney W. GrimesNull_bypass then builds a null-node 1798fae3551SRodney W. Grimesaliasing the UFS 1808fae3551SRodney W. Grimes.Pa sys 1818fae3551SRodney W. Grimesand returns this to the caller. 1828fae3551SRodney W. GrimesLater operations on the null-node 1838fae3551SRodney W. Grimes.Pa sys 1848fae3551SRodney W. Grimeswill repeat this 1858fae3551SRodney W. Grimesprocess when constructing other vnode stacks. 1868fae3551SRodney W. Grimes.\" 1878fae3551SRodney W. Grimes.\" 1888fae3551SRodney W. Grimes.Sh CREATING OTHER FILE SYSTEM LAYERS 1898fae3551SRodney W. GrimesOne of the easiest ways to construct new file system layers is to make 1908fae3551SRodney W. Grimesa copy of the null layer, rename all files and variables, and 1917b353f1aSPhilippe Charnierthen begin modifying the copy. 1927b353f1aSPhilippe Charnier.Xr Sed 1 1937b353f1aSPhilippe Charniercan be used to easily rename 1948fae3551SRodney W. Grimesall variables. 1958fae3551SRodney W. Grimes.Pp 1968fae3551SRodney W. GrimesThe umap layer is an example of a layer descended from the 1978fae3551SRodney W. Grimesnull layer. 1988fae3551SRodney W. Grimes.\" 1998fae3551SRodney W. Grimes.\" 2008fae3551SRodney W. Grimes.Sh INVOKING OPERATIONS ON LOWER LAYERS 2018fae3551SRodney W. GrimesThere are two techniques to invoke operations on a lower layer 2028fae3551SRodney W. Grimeswhen the operation cannot be completely bypassed. Each method 2038fae3551SRodney W. Grimesis appropriate in different situations. In both cases, 2048fae3551SRodney W. Grimesit is the responsibility of the aliasing layer to make 2058fae3551SRodney W. Grimesthe operation arguments "correct" for the lower layer 206f88b745fSTim Vanderhoekby mapping a vnode argument to the lower layer. 2078fae3551SRodney W. Grimes.Pp 2088fae3551SRodney W. GrimesThe first approach is to call the aliasing layer's bypass routine. 2098fae3551SRodney W. GrimesThis method is most suitable when you wish to invoke the operation 210f88b745fSTim Vanderhoekcurrently being handled on the lower layer. 211f88b745fSTim VanderhoekIt has the advantage that 212e83201b4SWolfram Schneiderthe bypass routine already must do argument mapping. 2138fae3551SRodney W. GrimesAn example of this is 2148fae3551SRodney W. Grimes.Em null_getattrs 2158fae3551SRodney W. Grimesin the null layer. 2168fae3551SRodney W. Grimes.Pp 217f88b745fSTim VanderhoekA second approach is to directly invoke vnode operations on 2188fae3551SRodney W. Grimesthe lower layer with the 2198fae3551SRodney W. Grimes.Em VOP_OPERATIONNAME 2208fae3551SRodney W. Grimesinterface. 2218fae3551SRodney W. GrimesThe advantage of this method is that it is easy to invoke 2228fae3551SRodney W. Grimesarbitrary operations on the lower layer. The disadvantage 223f88b745fSTim Vanderhoekis that vnode arguments must be manually mapped. 2248fae3551SRodney W. Grimes.\" 2258fae3551SRodney W. Grimes.\" 2268fae3551SRodney W. Grimes.Sh SEE ALSO 2278fae3551SRodney W. Grimes.Xr mount 8 228726b61abSRuslan Ermilov.Pp 2298fae3551SRodney W. GrimesUCLA Technical Report CSD-910056, 2308fae3551SRodney W. Grimes.Em "Stackable Layers: an Architecture for File System Development" . 231558408f9SJordan K. Hubbard.Sh BUGS 232558408f9SJordan K. HubbardTHIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK) 233558408f9SJordan K. HubbardAND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR 234558408f9SJordan K. HubbardOWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET. 2351252c1bbSRuslan Ermilov.Pp 236558408f9SJordan K. HubbardThis code also needs an owner in order to be less dangerous - serious 237558408f9SJordan K. Hubbardhackers can apply by sending mail to hackers@freebsd.org and announcing 238558408f9SJordan K. Hubbardtheir intent to take it over. 2398fae3551SRodney W. Grimes.Sh HISTORY 2408fae3551SRodney W. GrimesThe 2417b353f1aSPhilippe Charnier.Nm 242c0b0bcf4SMike Pritchardutility first appeared in 243c0b0bcf4SMike Pritchard.Bx 4.4 . 244