xref: /freebsd/sbin/mount_nullfs/mount_nullfs.8 (revision 1a720cbec513210fa2e85c3882741ef2f6dc5f35)
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.
17fbbd9655SWarner Losh.\" 3. 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.\"
334a2a69c4SKonstantin Belousov.Dd March 24, 2024
346ad10804SRuslan Ermilov.Dt MOUNT_NULLFS 8
356ad10804SRuslan Ermilov.Os
368fae3551SRodney W. Grimes.Sh NAME
376ad10804SRuslan Ermilov.Nm mount_nullfs
38eb083802SRuslan Ermilov.Nd "mount a loopback file system sub-tree; demonstrate the use of a null file system layer"
398fae3551SRodney W. Grimes.Sh SYNOPSIS
407c7fb079SRuslan Ermilov.Nm
418fae3551SRodney W. Grimes.Op Fl o Ar options
428fae3551SRodney W. Grimes.Ar target
438fae3551SRodney W. Grimes.Ar mount-point
448fae3551SRodney W. Grimes.Sh DESCRIPTION
458fae3551SRodney W. GrimesThe
467b353f1aSPhilippe Charnier.Nm
47e1205e80SPhilippe Charnierutility creates a
48*1a720cbeSAlexander Ziaee.Xr nullfs 4
49c9a1abe7STom Hukinslayer, duplicating a sub-tree of the file system
508fae3551SRodney W. Grimesname space under another part of the global file system namespace.
514a4c5285SPeter WemmThis allows existing files and directories to be accessed
524a4c5285SPeter Wemmusing a different pathname.
534a4c5285SPeter Wemm.Pp
544a4c5285SPeter WemmThe primary differences between a virtual copy of the file system
557c9bebf9SDima Dorfmanand a symbolic link are that the
564a4c5285SPeter Wemm.Xr getcwd 3
577c9bebf9SDima Dorfmanfunctions work correctly in the virtual copy, and that other file systems
584a4c5285SPeter Wemmmay be mounted on the virtual copy without affecting the original.
594a4c5285SPeter WemmA different device number for the virtual copy is returned by
604a4c5285SPeter Wemm.Xr stat 2 ,
614a4c5285SPeter Wemmbut in other respects it is indistinguishable from the original.
624a4c5285SPeter Wemm.Pp
634a4c5285SPeter WemmThe
647b353f1aSPhilippe Charnier.Nm
65a3f714c4SDoug Rabsonutility supports mounting both directories and single files.
66a3f714c4SDoug RabsonBoth
67a3f714c4SDoug Rabson.Ar target
68a3f714c4SDoug Rabsonand
69a3f714c4SDoug Rabson.Ar mount_point
70a3f714c4SDoug Rabsonmust be the same type.
71a3f714c4SDoug RabsonMounting directories to files or files to
72a3f714c4SDoug Rabsondirectories is not supported.
73a3f714c4SDoug Rabson.Pp
74a3f714c4SDoug RabsonThe
75a3f714c4SDoug Rabson.Nm
764a4c5285SPeter Wemmfile system differs from a traditional
774a4c5285SPeter Wemmloopback file system in two respects: it is implemented using
78a8e1969bSCeri Daviesa stackable layers techniques, and its
79d90d7015SRuslan Ermilov.Do null-node Dc Ns s
808fae3551SRodney W. Grimesstack above
818fae3551SRodney W. Grimesall lower-layer vnodes, not just over directory vnodes.
828fae3551SRodney W. Grimes.Pp
838fae3551SRodney W. GrimesThe options are as follows:
848fae3551SRodney W. Grimes.Bl -tag -width indent
858fae3551SRodney W. Grimes.It Fl o
868fae3551SRodney W. GrimesOptions are specified with a
878fae3551SRodney W. Grimes.Fl o
888fae3551SRodney W. Grimesflag followed by a comma separated string of options.
898fae3551SRodney W. GrimesSee the
908fae3551SRodney W. Grimes.Xr mount 8
918fae3551SRodney W. Grimesman page for possible options and their meanings.
92b7564477SAlexander LeidingerAdditionally the following option is supported:
934a2a69c4SKonstantin Belousov.Bl -tag -width nocache
94b7564477SAlexander Leidinger.It Cm nocache
95b29fb6cfSAlexander LeidingerDisable metadata caching in the null layer.
96b7564477SAlexander LeidingerSome lower-layer file systems may force this option.
97b29fb6cfSAlexander LeidingerDepending on the access pattern,
98b29fb6cfSAlexander Leidingerthis may result in increased lock contention.
994a2a69c4SKonstantin Belousov.It Cm cache
100bdf1587aSKonstantin BelousovForce enable metadata caching.
101b7564477SAlexander Leidinger.El
1028fae3551SRodney W. Grimes.El
1038fae3551SRodney W. Grimes.Pp
1044a2a69c4SKonstantin BelousovThe
1054a2a69c4SKonstantin Belousov.Dv vfs.nullfs.cache_vnodes
1064a2a69c4SKonstantin Belousovsysctl specifies global default for mount-specific cache/nocache option.
1074a2a69c4SKonstantin Belousov.Pp
1088fae3551SRodney W. GrimesThe null layer has two purposes.
109b210d5f6SJoerg WunschFirst, it serves as a demonstration of layering by providing a layer
1108fae3551SRodney W. Grimeswhich does nothing.
1118fae3551SRodney W. Grimes(It actually does everything the loopback file system does,
1128fae3551SRodney W. Grimeswhich is slightly more than nothing.)
1138fae3551SRodney W. GrimesSecond, the null layer can serve as a prototype layer.
1148fae3551SRodney W. GrimesSince it provides all necessary layer framework,
115f88b745fSTim Vanderhoeknew file system layers can be created very easily by starting
1168fae3551SRodney W. Grimeswith a null layer.
1178fae3551SRodney W. Grimes.Pp
1188fae3551SRodney W. GrimesThe remainder of this man page examines the null layer as a basis
1198fae3551SRodney W. Grimesfor constructing new layers.
1208fae3551SRodney W. Grimes.\"
1218fae3551SRodney W. Grimes.\"
1228fae3551SRodney W. Grimes.Sh INSTANTIATING NEW NULL LAYERS
1238fae3551SRodney W. GrimesNew null layers are created with
1246ad10804SRuslan Ermilov.Nm .
125e1205e80SPhilippe CharnierThe
126e1205e80SPhilippe Charnier.Nm
127e1205e80SPhilippe Charnierutility takes two arguments, the pathname
1288fae3551SRodney W. Grimesof the lower vfs (target-pn) and the pathname where the null
1299806e231SRuslan Ermilovlayer will appear in the namespace (mount-point-pn).
1309806e231SRuslan ErmilovAfter
1318fae3551SRodney W. Grimesthe null layer is put into place, the contents
1328fae3551SRodney W. Grimesof target-pn subtree will be aliased under mount-point-pn.
1338fae3551SRodney W. Grimes.\"
1348fae3551SRodney W. Grimes.\"
1358fae3551SRodney W. Grimes.Sh OPERATION OF A NULL LAYER
1368fae3551SRodney W. GrimesThe null layer is the minimum file system layer,
1378fae3551SRodney W. Grimessimply bypassing all possible operations to the lower layer
1389806e231SRuslan Ermilovfor processing there.
1399806e231SRuslan ErmilovThe majority of its activity centers
140f88b745fSTim Vanderhoekon the bypass routine, through which nearly all vnode operations
1418fae3551SRodney W. Grimespass.
1428fae3551SRodney W. Grimes.Pp
1438fae3551SRodney W. GrimesThe bypass routine accepts arbitrary vnode operations for
1449806e231SRuslan Ermilovhandling by the lower layer.
1459806e231SRuslan ErmilovIt begins by examining vnode
1468fae3551SRodney W. Grimesoperation arguments and replacing any null-nodes by their
1479806e231SRuslan Ermilovlower-layer equivalents.
1489806e231SRuslan ErmilovIt then invokes the operation
1499806e231SRuslan Ermilovon the lower layer.
1509806e231SRuslan ErmilovFinally, it replaces the null-nodes
1518fae3551SRodney W. Grimesin the arguments and, if a vnode is returned by the operation,
1528fae3551SRodney W. Grimesstacks a null-node on top of the returned vnode.
1538fae3551SRodney W. Grimes.Pp
1548fae3551SRodney W. GrimesAlthough bypass handles most operations,
1558fae3551SRodney W. Grimes.Em vop_getattr ,
1568fae3551SRodney W. Grimes.Em vop_inactive ,
1578fae3551SRodney W. Grimes.Em vop_reclaim ,
1588fae3551SRodney W. Grimesand
1598fae3551SRodney W. Grimes.Em vop_print
1608fae3551SRodney W. Grimesare not bypassed.
1618fae3551SRodney W. Grimes.Em Vop_getattr
1628fae3551SRodney W. Grimesmust change the fsid being returned.
1638fae3551SRodney W. Grimes.Em Vop_inactive
164f88b745fSTim Vanderhoekand
165f88b745fSTim Vanderhoek.Em vop_reclaim
166f88b745fSTim Vanderhoekare not bypassed so that
1678fae3551SRodney W. Grimesthey can handle freeing null-layer specific data.
1688fae3551SRodney W. Grimes.Em Vop_print
1698fae3551SRodney W. Grimesis not bypassed to avoid excessive debugging
1708fae3551SRodney W. Grimesinformation.
1718fae3551SRodney W. Grimes.\"
1728fae3551SRodney W. Grimes.\"
1738fae3551SRodney W. Grimes.Sh INSTANTIATING VNODE STACKS
1748fae3551SRodney W. GrimesMounting associates the null layer with a lower layer,
1759806e231SRuslan Ermilovin effect stacking two VFSes.
1769806e231SRuslan ErmilovVnode stacks are instead
1778fae3551SRodney W. Grimescreated on demand as files are accessed.
1788fae3551SRodney W. Grimes.Pp
1798fae3551SRodney W. GrimesThe initial mount creates a single vnode stack for the
1809806e231SRuslan Ermilovroot of the new null layer.
1819806e231SRuslan ErmilovAll other vnode stacks
1828fae3551SRodney W. Grimesare created as a result of vnode operations on
1838fae3551SRodney W. Grimesthis or other null vnode stacks.
1848fae3551SRodney W. Grimes.Pp
1858fae3551SRodney W. GrimesNew vnode stacks come into existence as a result of
1868fae3551SRodney W. Grimesan operation which returns a vnode.
1878fae3551SRodney W. GrimesThe bypass routine stacks a null-node above the new
1888fae3551SRodney W. Grimesvnode before returning it to the caller.
1898fae3551SRodney W. Grimes.Pp
1908fae3551SRodney W. GrimesFor example, imagine mounting a null layer with
1918fae3551SRodney W. Grimes.Bd -literal -offset indent
1926ad10804SRuslan Ermilovmount_nullfs /usr/include /dev/layer/null
1938fae3551SRodney W. Grimes.Ed
1947c8f6a22SChristian Brueffer.Pp
1958fae3551SRodney W. GrimesChanging directory to
1968fae3551SRodney W. Grimes.Pa /dev/layer/null
1978fae3551SRodney W. Grimeswill assign
1988fae3551SRodney W. Grimesthe root null-node (which was created when the null layer was mounted).
1998fae3551SRodney W. GrimesNow consider opening
2008fae3551SRodney W. Grimes.Pa sys .
2018fae3551SRodney W. GrimesA vop_lookup would be
2029806e231SRuslan Ermilovdone on the root null-node.
2039806e231SRuslan ErmilovThis operation would bypass through
2048fae3551SRodney W. Grimesto the lower layer which would return a vnode representing
2058fae3551SRodney W. Grimesthe UFS
2068fae3551SRodney W. Grimes.Pa sys .
2078fae3551SRodney W. GrimesNull_bypass then builds a null-node
2088fae3551SRodney W. Grimesaliasing the UFS
2098fae3551SRodney W. Grimes.Pa sys
2108fae3551SRodney W. Grimesand returns this to the caller.
2118fae3551SRodney W. GrimesLater operations on the null-node
2128fae3551SRodney W. Grimes.Pa sys
2138fae3551SRodney W. Grimeswill repeat this
2148fae3551SRodney W. Grimesprocess when constructing other vnode stacks.
2158fae3551SRodney W. Grimes.\"
2168fae3551SRodney W. Grimes.\"
2178fae3551SRodney W. Grimes.Sh CREATING OTHER FILE SYSTEM LAYERS
2188fae3551SRodney W. GrimesOne of the easiest ways to construct new file system layers is to make
2198fae3551SRodney W. Grimesa copy of the null layer, rename all files and variables, and
2207b353f1aSPhilippe Charnierthen begin modifying the copy.
221c7407685SPhilippe CharnierThe
222c7407685SPhilippe Charnier.Xr sed 1
223c7407685SPhilippe Charnierutility can be used to easily rename
2248fae3551SRodney W. Grimesall variables.
2258fae3551SRodney W. Grimes.Pp
2268fae3551SRodney W. GrimesThe umap layer is an example of a layer descended from the
2278fae3551SRodney W. Grimesnull layer.
2288fae3551SRodney W. Grimes.\"
2298fae3551SRodney W. Grimes.\"
2308fae3551SRodney W. Grimes.Sh INVOKING OPERATIONS ON LOWER LAYERS
2318fae3551SRodney W. GrimesThere are two techniques to invoke operations on a lower layer
2329806e231SRuslan Ermilovwhen the operation cannot be completely bypassed.
2339806e231SRuslan ErmilovEach method
2349806e231SRuslan Ermilovis appropriate in different situations.
2359806e231SRuslan ErmilovIn both cases,
2368fae3551SRodney W. Grimesit is the responsibility of the aliasing layer to make
2378fae3551SRodney W. Grimesthe operation arguments "correct" for the lower layer
238f88b745fSTim Vanderhoekby mapping a vnode argument to the lower layer.
2398fae3551SRodney W. Grimes.Pp
2408fae3551SRodney W. GrimesThe first approach is to call the aliasing layer's bypass routine.
2418fae3551SRodney W. GrimesThis method is most suitable when you wish to invoke the operation
242f88b745fSTim Vanderhoekcurrently being handled on the lower layer.
243f88b745fSTim VanderhoekIt has the advantage that
244e83201b4SWolfram Schneiderthe bypass routine already must do argument mapping.
2458fae3551SRodney W. GrimesAn example of this is
2468fae3551SRodney W. Grimes.Em null_getattrs
2478fae3551SRodney W. Grimesin the null layer.
2488fae3551SRodney W. Grimes.Pp
249f88b745fSTim VanderhoekA second approach is to directly invoke vnode operations on
2508fae3551SRodney W. Grimesthe lower layer with the
2518fae3551SRodney W. Grimes.Em VOP_OPERATIONNAME
2528fae3551SRodney W. Grimesinterface.
2538fae3551SRodney W. GrimesThe advantage of this method is that it is easy to invoke
2549806e231SRuslan Ermilovarbitrary operations on the lower layer.
2559806e231SRuslan ErmilovThe disadvantage
256f88b745fSTim Vanderhoekis that vnode arguments must be manually mapped.
2578fae3551SRodney W. Grimes.\"
2588fae3551SRodney W. Grimes.\"
2598fae3551SRodney W. Grimes.Sh SEE ALSO
260*1a720cbeSAlexander Ziaee.Xr nullfs 4 ,
2618fae3551SRodney W. Grimes.Xr mount 8
262726b61abSRuslan Ermilov.Pp
2638fae3551SRodney W. GrimesUCLA Technical Report CSD-910056,
2648fae3551SRodney W. Grimes.Em "Stackable Layers: an Architecture for File System Development" .
2656087df9eSRuslan Ermilov.Sh HISTORY
2666087df9eSRuslan ErmilovThe
267e8533061SSevan Janiyan.Nm mount_null
2686087df9eSRuslan Ermilovutility first appeared in
2696087df9eSRuslan Ermilov.Bx 4.4 .
270e8533061SSevan JaniyanIt was renamed to
271e8533061SSevan Janiyan.Nm
272e8533061SSevan Janiyanin
273e8533061SSevan Janiyan.Fx 5.0 .
274