xref: /freebsd/sbin/mount_nullfs/mount_nullfs.8 (revision 7c8f6a22d4a61e5b1c5d41ecf54734b5e522e700)
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.\" 4. Neither the name of the University nor the names of its contributors
188fae3551SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
198fae3551SRodney W. Grimes.\"    without specific prior written permission.
208fae3551SRodney W. Grimes.\"
218fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
228fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
238fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
248fae3551SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
258fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
268fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
278fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
288fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
298fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
308fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
318fae3551SRodney W. Grimes.\" SUCH DAMAGE.
328fae3551SRodney W. Grimes.\"
334a4c5285SPeter Wemm.\"     @(#)mount_null.8	8.6 (Berkeley) 5/1/95
347f3dea24SPeter Wemm.\" $FreeBSD$
358fae3551SRodney W. Grimes.\"
364a4c5285SPeter Wemm.Dd May 1, 1995
376ad10804SRuslan Ermilov.Dt MOUNT_NULLFS 8
386ad10804SRuslan Ermilov.Os
398fae3551SRodney W. Grimes.Sh NAME
406ad10804SRuslan Ermilov.Nm mount_nullfs
41eb083802SRuslan Ermilov.Nd "mount a loopback file system sub-tree; demonstrate the use of a null file system layer"
428fae3551SRodney W. Grimes.Sh SYNOPSIS
437c7fb079SRuslan Ermilov.Nm
448fae3551SRodney W. Grimes.Op Fl o Ar options
458fae3551SRodney W. Grimes.Ar target
468fae3551SRodney W. Grimes.Ar mount-point
478fae3551SRodney W. Grimes.Sh DESCRIPTION
488fae3551SRodney W. GrimesThe
497b353f1aSPhilippe Charnier.Nm
50e1205e80SPhilippe Charnierutility creates a
518fae3551SRodney W. Grimesnull layer, duplicating a sub-tree of the file system
528fae3551SRodney W. Grimesname space under another part of the global file system namespace.
534a4c5285SPeter WemmThis allows existing files and directories to be accessed
544a4c5285SPeter Wemmusing a different pathname.
554a4c5285SPeter Wemm.Pp
564a4c5285SPeter WemmThe primary differences between a virtual copy of the file system
577c9bebf9SDima Dorfmanand a symbolic link are that the
584a4c5285SPeter Wemm.Xr getcwd 3
597c9bebf9SDima Dorfmanfunctions work correctly in the virtual copy, and that other file systems
604a4c5285SPeter Wemmmay be mounted on the virtual copy without affecting the original.
614a4c5285SPeter WemmA different device number for the virtual copy is returned by
624a4c5285SPeter Wemm.Xr stat 2 ,
634a4c5285SPeter Wemmbut in other respects it is indistinguishable from the original.
644a4c5285SPeter Wemm.Pp
654a4c5285SPeter WemmThe
667b353f1aSPhilippe Charnier.Nm
674a4c5285SPeter Wemmfile system differs from a traditional
684a4c5285SPeter Wemmloopback file system in two respects: it is implemented using
69a8e1969bSCeri Daviesa stackable layers techniques, and its
70d90d7015SRuslan Ermilov.Do null-node Dc Ns s
718fae3551SRodney W. Grimesstack above
728fae3551SRodney W. Grimesall lower-layer vnodes, not just over directory vnodes.
738fae3551SRodney W. Grimes.Pp
748fae3551SRodney W. GrimesThe options are as follows:
758fae3551SRodney W. Grimes.Bl -tag -width indent
768fae3551SRodney W. Grimes.It Fl o
778fae3551SRodney W. GrimesOptions are specified with a
788fae3551SRodney W. Grimes.Fl o
798fae3551SRodney W. Grimesflag followed by a comma separated string of options.
808fae3551SRodney W. GrimesSee the
818fae3551SRodney W. Grimes.Xr mount 8
828fae3551SRodney W. Grimesman page for possible options and their meanings.
838fae3551SRodney W. Grimes.El
848fae3551SRodney W. Grimes.Pp
858fae3551SRodney W. GrimesThe null layer has two purposes.
86b210d5f6SJoerg WunschFirst, it serves as a demonstration of layering by providing a layer
878fae3551SRodney W. Grimeswhich does nothing.
888fae3551SRodney W. Grimes(It actually does everything the loopback file system does,
898fae3551SRodney W. Grimeswhich is slightly more than nothing.)
908fae3551SRodney W. GrimesSecond, the null layer can serve as a prototype layer.
918fae3551SRodney W. GrimesSince it provides all necessary layer framework,
92f88b745fSTim Vanderhoeknew file system layers can be created very easily by starting
938fae3551SRodney W. Grimeswith a null layer.
948fae3551SRodney W. Grimes.Pp
958fae3551SRodney W. GrimesThe remainder of this man page examines the null layer as a basis
968fae3551SRodney W. Grimesfor constructing new layers.
978fae3551SRodney W. Grimes.\"
988fae3551SRodney W. Grimes.\"
998fae3551SRodney W. Grimes.Sh INSTANTIATING NEW NULL LAYERS
1008fae3551SRodney W. GrimesNew null layers are created with
1016ad10804SRuslan Ermilov.Nm .
102e1205e80SPhilippe CharnierThe
103e1205e80SPhilippe Charnier.Nm
104e1205e80SPhilippe Charnierutility takes two arguments, the pathname
1058fae3551SRodney W. Grimesof the lower vfs (target-pn) and the pathname where the null
1069806e231SRuslan Ermilovlayer will appear in the namespace (mount-point-pn).
1079806e231SRuslan ErmilovAfter
1088fae3551SRodney W. Grimesthe null layer is put into place, the contents
1098fae3551SRodney W. Grimesof target-pn subtree will be aliased under mount-point-pn.
1108fae3551SRodney W. Grimes.\"
1118fae3551SRodney W. Grimes.\"
1128fae3551SRodney W. Grimes.Sh OPERATION OF A NULL LAYER
1138fae3551SRodney W. GrimesThe null layer is the minimum file system layer,
1148fae3551SRodney W. Grimessimply bypassing all possible operations to the lower layer
1159806e231SRuslan Ermilovfor processing there.
1169806e231SRuslan ErmilovThe majority of its activity centers
117f88b745fSTim Vanderhoekon the bypass routine, through which nearly all vnode operations
1188fae3551SRodney W. Grimespass.
1198fae3551SRodney W. Grimes.Pp
1208fae3551SRodney W. GrimesThe bypass routine accepts arbitrary vnode operations for
1219806e231SRuslan Ermilovhandling by the lower layer.
1229806e231SRuslan ErmilovIt begins by examining vnode
1238fae3551SRodney W. Grimesoperation arguments and replacing any null-nodes by their
1249806e231SRuslan Ermilovlower-layer equivalents.
1259806e231SRuslan ErmilovIt then invokes the operation
1269806e231SRuslan Ermilovon the lower layer.
1279806e231SRuslan ErmilovFinally, it replaces the null-nodes
1288fae3551SRodney W. Grimesin the arguments and, if a vnode is returned by the operation,
1298fae3551SRodney W. Grimesstacks a null-node on top of the returned vnode.
1308fae3551SRodney W. Grimes.Pp
1318fae3551SRodney W. GrimesAlthough bypass handles most operations,
1328fae3551SRodney W. Grimes.Em vop_getattr ,
1338fae3551SRodney W. Grimes.Em vop_inactive ,
1348fae3551SRodney W. Grimes.Em vop_reclaim ,
1358fae3551SRodney W. Grimesand
1368fae3551SRodney W. Grimes.Em vop_print
1378fae3551SRodney W. Grimesare not bypassed.
1388fae3551SRodney W. Grimes.Em Vop_getattr
1398fae3551SRodney W. Grimesmust change the fsid being returned.
1408fae3551SRodney W. Grimes.Em Vop_inactive
141f88b745fSTim Vanderhoekand
142f88b745fSTim Vanderhoek.Em vop_reclaim
143f88b745fSTim Vanderhoekare not bypassed so that
1448fae3551SRodney W. Grimesthey can handle freeing null-layer specific data.
1458fae3551SRodney W. Grimes.Em Vop_print
1468fae3551SRodney W. Grimesis not bypassed to avoid excessive debugging
1478fae3551SRodney W. Grimesinformation.
1488fae3551SRodney W. Grimes.\"
1498fae3551SRodney W. Grimes.\"
1508fae3551SRodney W. Grimes.Sh INSTANTIATING VNODE STACKS
1518fae3551SRodney W. GrimesMounting associates the null layer with a lower layer,
1529806e231SRuslan Ermilovin effect stacking two VFSes.
1539806e231SRuslan ErmilovVnode 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
1579806e231SRuslan Ermilovroot of the new null layer.
1589806e231SRuslan ErmilovAll other vnode stacks
1598fae3551SRodney W. Grimesare created as a result of vnode operations on
1608fae3551SRodney W. Grimesthis or other null vnode stacks.
1618fae3551SRodney W. Grimes.Pp
1628fae3551SRodney W. GrimesNew vnode stacks come into existence as a result of
1638fae3551SRodney W. Grimesan operation which returns a vnode.
1648fae3551SRodney W. GrimesThe bypass routine stacks a null-node above the new
1658fae3551SRodney W. Grimesvnode before returning it to the caller.
1668fae3551SRodney W. Grimes.Pp
1678fae3551SRodney W. GrimesFor example, imagine mounting a null layer with
1688fae3551SRodney W. Grimes.Bd -literal -offset indent
1696ad10804SRuslan Ermilovmount_nullfs /usr/include /dev/layer/null
1708fae3551SRodney W. Grimes.Ed
1717c8f6a22SChristian Brueffer.Pp
1728fae3551SRodney W. GrimesChanging directory to
1738fae3551SRodney W. Grimes.Pa /dev/layer/null
1748fae3551SRodney W. Grimeswill assign
1758fae3551SRodney W. Grimesthe root null-node (which was created when the null layer was mounted).
1768fae3551SRodney W. GrimesNow consider opening
1778fae3551SRodney W. Grimes.Pa sys .
1788fae3551SRodney W. GrimesA vop_lookup would be
1799806e231SRuslan Ermilovdone on the root null-node.
1809806e231SRuslan ErmilovThis operation would bypass through
1818fae3551SRodney W. Grimesto the lower layer which would return a vnode representing
1828fae3551SRodney W. Grimesthe UFS
1838fae3551SRodney W. Grimes.Pa sys .
1848fae3551SRodney W. GrimesNull_bypass then builds a null-node
1858fae3551SRodney W. Grimesaliasing the UFS
1868fae3551SRodney W. Grimes.Pa sys
1878fae3551SRodney W. Grimesand returns this to the caller.
1888fae3551SRodney W. GrimesLater operations on the null-node
1898fae3551SRodney W. Grimes.Pa sys
1908fae3551SRodney W. Grimeswill repeat this
1918fae3551SRodney W. Grimesprocess when constructing other vnode stacks.
1928fae3551SRodney W. Grimes.\"
1938fae3551SRodney W. Grimes.\"
1948fae3551SRodney W. Grimes.Sh CREATING OTHER FILE SYSTEM LAYERS
1958fae3551SRodney W. GrimesOne of the easiest ways to construct new file system layers is to make
1968fae3551SRodney W. Grimesa copy of the null layer, rename all files and variables, and
1977b353f1aSPhilippe Charnierthen begin modifying the copy.
198c7407685SPhilippe CharnierThe
199c7407685SPhilippe Charnier.Xr sed 1
200c7407685SPhilippe Charnierutility can be used to easily rename
2018fae3551SRodney W. Grimesall variables.
2028fae3551SRodney W. Grimes.Pp
2038fae3551SRodney W. GrimesThe umap layer is an example of a layer descended from the
2048fae3551SRodney W. Grimesnull layer.
2058fae3551SRodney W. Grimes.\"
2068fae3551SRodney W. Grimes.\"
2078fae3551SRodney W. Grimes.Sh INVOKING OPERATIONS ON LOWER LAYERS
2088fae3551SRodney W. GrimesThere are two techniques to invoke operations on a lower layer
2099806e231SRuslan Ermilovwhen the operation cannot be completely bypassed.
2109806e231SRuslan ErmilovEach method
2119806e231SRuslan Ermilovis appropriate in different situations.
2129806e231SRuslan ErmilovIn both cases,
2138fae3551SRodney W. Grimesit is the responsibility of the aliasing layer to make
2148fae3551SRodney W. Grimesthe operation arguments "correct" for the lower layer
215f88b745fSTim Vanderhoekby mapping a vnode argument to the lower layer.
2168fae3551SRodney W. Grimes.Pp
2178fae3551SRodney W. GrimesThe first approach is to call the aliasing layer's bypass routine.
2188fae3551SRodney W. GrimesThis method is most suitable when you wish to invoke the operation
219f88b745fSTim Vanderhoekcurrently being handled on the lower layer.
220f88b745fSTim VanderhoekIt has the advantage that
221e83201b4SWolfram Schneiderthe bypass routine already must do argument mapping.
2228fae3551SRodney W. GrimesAn example of this is
2238fae3551SRodney W. Grimes.Em null_getattrs
2248fae3551SRodney W. Grimesin the null layer.
2258fae3551SRodney W. Grimes.Pp
226f88b745fSTim VanderhoekA second approach is to directly invoke vnode operations on
2278fae3551SRodney W. Grimesthe lower layer with the
2288fae3551SRodney W. Grimes.Em VOP_OPERATIONNAME
2298fae3551SRodney W. Grimesinterface.
2308fae3551SRodney W. GrimesThe advantage of this method is that it is easy to invoke
2319806e231SRuslan Ermilovarbitrary operations on the lower layer.
2329806e231SRuslan ErmilovThe disadvantage
233f88b745fSTim Vanderhoekis that vnode arguments must be manually mapped.
2348fae3551SRodney W. Grimes.\"
2358fae3551SRodney W. Grimes.\"
2368fae3551SRodney W. Grimes.Sh SEE ALSO
2378fae3551SRodney W. Grimes.Xr mount 8
238726b61abSRuslan Ermilov.Pp
2398fae3551SRodney W. GrimesUCLA Technical Report CSD-910056,
2408fae3551SRodney W. Grimes.Em "Stackable Layers: an Architecture for File System Development" .
2416087df9eSRuslan Ermilov.Sh HISTORY
2426087df9eSRuslan ErmilovThe
2436087df9eSRuslan Ermilov.Nm
2446087df9eSRuslan Ermilovutility first appeared in
2456087df9eSRuslan Ermilov.Bx 4.4 .
246