xref: /freebsd/sbin/mount_nullfs/mount_nullfs.8 (revision b29fb6cffd025dea9fb51e7c61c7f8e4f380ff4e)
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.\"
334a4c5285SPeter Wemm.\"     @(#)mount_null.8	8.6 (Berkeley) 5/1/95
347f3dea24SPeter Wemm.\" $FreeBSD$
358fae3551SRodney W. Grimes.\"
36*b29fb6cfSAlexander Leidinger.Dd May 6, 2022
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.
83b7564477SAlexander LeidingerAdditionally the following option is supported:
84b7564477SAlexander Leidinger.Bl -tag -width indent
85b7564477SAlexander Leidinger.It Cm nocache
86*b29fb6cfSAlexander LeidingerDisable metadata caching in the null layer.
87b7564477SAlexander LeidingerSome lower-layer file systems may force this option.
88*b29fb6cfSAlexander LeidingerDepending on the access pattern,
89*b29fb6cfSAlexander Leidingerthis may result in increased lock contention.
90b7564477SAlexander Leidinger.El
918fae3551SRodney W. Grimes.El
928fae3551SRodney W. Grimes.Pp
938fae3551SRodney W. GrimesThe null layer has two purposes.
94b210d5f6SJoerg WunschFirst, it serves as a demonstration of layering by providing a layer
958fae3551SRodney W. Grimeswhich does nothing.
968fae3551SRodney W. Grimes(It actually does everything the loopback file system does,
978fae3551SRodney W. Grimeswhich is slightly more than nothing.)
988fae3551SRodney W. GrimesSecond, the null layer can serve as a prototype layer.
998fae3551SRodney W. GrimesSince it provides all necessary layer framework,
100f88b745fSTim Vanderhoeknew file system layers can be created very easily by starting
1018fae3551SRodney W. Grimeswith a null layer.
1028fae3551SRodney W. Grimes.Pp
1038fae3551SRodney W. GrimesThe remainder of this man page examines the null layer as a basis
1048fae3551SRodney W. Grimesfor constructing new layers.
1058fae3551SRodney W. Grimes.\"
1068fae3551SRodney W. Grimes.\"
1078fae3551SRodney W. Grimes.Sh INSTANTIATING NEW NULL LAYERS
1088fae3551SRodney W. GrimesNew null layers are created with
1096ad10804SRuslan Ermilov.Nm .
110e1205e80SPhilippe CharnierThe
111e1205e80SPhilippe Charnier.Nm
112e1205e80SPhilippe Charnierutility takes two arguments, the pathname
1138fae3551SRodney W. Grimesof the lower vfs (target-pn) and the pathname where the null
1149806e231SRuslan Ermilovlayer will appear in the namespace (mount-point-pn).
1159806e231SRuslan ErmilovAfter
1168fae3551SRodney W. Grimesthe null layer is put into place, the contents
1178fae3551SRodney W. Grimesof target-pn subtree will be aliased under mount-point-pn.
1188fae3551SRodney W. Grimes.\"
1198fae3551SRodney W. Grimes.\"
1208fae3551SRodney W. Grimes.Sh OPERATION OF A NULL LAYER
1218fae3551SRodney W. GrimesThe null layer is the minimum file system layer,
1228fae3551SRodney W. Grimessimply bypassing all possible operations to the lower layer
1239806e231SRuslan Ermilovfor processing there.
1249806e231SRuslan ErmilovThe majority of its activity centers
125f88b745fSTim Vanderhoekon the bypass routine, through which nearly all vnode operations
1268fae3551SRodney W. Grimespass.
1278fae3551SRodney W. Grimes.Pp
1288fae3551SRodney W. GrimesThe bypass routine accepts arbitrary vnode operations for
1299806e231SRuslan Ermilovhandling by the lower layer.
1309806e231SRuslan ErmilovIt begins by examining vnode
1318fae3551SRodney W. Grimesoperation arguments and replacing any null-nodes by their
1329806e231SRuslan Ermilovlower-layer equivalents.
1339806e231SRuslan ErmilovIt then invokes the operation
1349806e231SRuslan Ermilovon the lower layer.
1359806e231SRuslan ErmilovFinally, it replaces the null-nodes
1368fae3551SRodney W. Grimesin the arguments and, if a vnode is returned by the operation,
1378fae3551SRodney W. Grimesstacks a null-node on top of the returned vnode.
1388fae3551SRodney W. Grimes.Pp
1398fae3551SRodney W. GrimesAlthough bypass handles most operations,
1408fae3551SRodney W. Grimes.Em vop_getattr ,
1418fae3551SRodney W. Grimes.Em vop_inactive ,
1428fae3551SRodney W. Grimes.Em vop_reclaim ,
1438fae3551SRodney W. Grimesand
1448fae3551SRodney W. Grimes.Em vop_print
1458fae3551SRodney W. Grimesare not bypassed.
1468fae3551SRodney W. Grimes.Em Vop_getattr
1478fae3551SRodney W. Grimesmust change the fsid being returned.
1488fae3551SRodney W. Grimes.Em Vop_inactive
149f88b745fSTim Vanderhoekand
150f88b745fSTim Vanderhoek.Em vop_reclaim
151f88b745fSTim Vanderhoekare not bypassed so that
1528fae3551SRodney W. Grimesthey can handle freeing null-layer specific data.
1538fae3551SRodney W. Grimes.Em Vop_print
1548fae3551SRodney W. Grimesis not bypassed to avoid excessive debugging
1558fae3551SRodney W. Grimesinformation.
1568fae3551SRodney W. Grimes.\"
1578fae3551SRodney W. Grimes.\"
1588fae3551SRodney W. Grimes.Sh INSTANTIATING VNODE STACKS
1598fae3551SRodney W. GrimesMounting associates the null layer with a lower layer,
1609806e231SRuslan Ermilovin effect stacking two VFSes.
1619806e231SRuslan ErmilovVnode stacks are instead
1628fae3551SRodney W. Grimescreated on demand as files are accessed.
1638fae3551SRodney W. Grimes.Pp
1648fae3551SRodney W. GrimesThe initial mount creates a single vnode stack for the
1659806e231SRuslan Ermilovroot of the new null layer.
1669806e231SRuslan ErmilovAll other vnode stacks
1678fae3551SRodney W. Grimesare created as a result of vnode operations on
1688fae3551SRodney W. Grimesthis or other null vnode stacks.
1698fae3551SRodney W. Grimes.Pp
1708fae3551SRodney W. GrimesNew vnode stacks come into existence as a result of
1718fae3551SRodney W. Grimesan operation which returns a vnode.
1728fae3551SRodney W. GrimesThe bypass routine stacks a null-node above the new
1738fae3551SRodney W. Grimesvnode before returning it to the caller.
1748fae3551SRodney W. Grimes.Pp
1758fae3551SRodney W. GrimesFor example, imagine mounting a null layer with
1768fae3551SRodney W. Grimes.Bd -literal -offset indent
1776ad10804SRuslan Ermilovmount_nullfs /usr/include /dev/layer/null
1788fae3551SRodney W. Grimes.Ed
1797c8f6a22SChristian Brueffer.Pp
1808fae3551SRodney W. GrimesChanging directory to
1818fae3551SRodney W. Grimes.Pa /dev/layer/null
1828fae3551SRodney W. Grimeswill assign
1838fae3551SRodney W. Grimesthe root null-node (which was created when the null layer was mounted).
1848fae3551SRodney W. GrimesNow consider opening
1858fae3551SRodney W. Grimes.Pa sys .
1868fae3551SRodney W. GrimesA vop_lookup would be
1879806e231SRuslan Ermilovdone on the root null-node.
1889806e231SRuslan ErmilovThis operation would bypass through
1898fae3551SRodney W. Grimesto the lower layer which would return a vnode representing
1908fae3551SRodney W. Grimesthe UFS
1918fae3551SRodney W. Grimes.Pa sys .
1928fae3551SRodney W. GrimesNull_bypass then builds a null-node
1938fae3551SRodney W. Grimesaliasing the UFS
1948fae3551SRodney W. Grimes.Pa sys
1958fae3551SRodney W. Grimesand returns this to the caller.
1968fae3551SRodney W. GrimesLater operations on the null-node
1978fae3551SRodney W. Grimes.Pa sys
1988fae3551SRodney W. Grimeswill repeat this
1998fae3551SRodney W. Grimesprocess when constructing other vnode stacks.
2008fae3551SRodney W. Grimes.\"
2018fae3551SRodney W. Grimes.\"
2028fae3551SRodney W. Grimes.Sh CREATING OTHER FILE SYSTEM LAYERS
2038fae3551SRodney W. GrimesOne of the easiest ways to construct new file system layers is to make
2048fae3551SRodney W. Grimesa copy of the null layer, rename all files and variables, and
2057b353f1aSPhilippe Charnierthen begin modifying the copy.
206c7407685SPhilippe CharnierThe
207c7407685SPhilippe Charnier.Xr sed 1
208c7407685SPhilippe Charnierutility can be used to easily rename
2098fae3551SRodney W. Grimesall variables.
2108fae3551SRodney W. Grimes.Pp
2118fae3551SRodney W. GrimesThe umap layer is an example of a layer descended from the
2128fae3551SRodney W. Grimesnull layer.
2138fae3551SRodney W. Grimes.\"
2148fae3551SRodney W. Grimes.\"
2158fae3551SRodney W. Grimes.Sh INVOKING OPERATIONS ON LOWER LAYERS
2168fae3551SRodney W. GrimesThere are two techniques to invoke operations on a lower layer
2179806e231SRuslan Ermilovwhen the operation cannot be completely bypassed.
2189806e231SRuslan ErmilovEach method
2199806e231SRuslan Ermilovis appropriate in different situations.
2209806e231SRuslan ErmilovIn both cases,
2218fae3551SRodney W. Grimesit is the responsibility of the aliasing layer to make
2228fae3551SRodney W. Grimesthe operation arguments "correct" for the lower layer
223f88b745fSTim Vanderhoekby mapping a vnode argument to the lower layer.
2248fae3551SRodney W. Grimes.Pp
2258fae3551SRodney W. GrimesThe first approach is to call the aliasing layer's bypass routine.
2268fae3551SRodney W. GrimesThis method is most suitable when you wish to invoke the operation
227f88b745fSTim Vanderhoekcurrently being handled on the lower layer.
228f88b745fSTim VanderhoekIt has the advantage that
229e83201b4SWolfram Schneiderthe bypass routine already must do argument mapping.
2308fae3551SRodney W. GrimesAn example of this is
2318fae3551SRodney W. Grimes.Em null_getattrs
2328fae3551SRodney W. Grimesin the null layer.
2338fae3551SRodney W. Grimes.Pp
234f88b745fSTim VanderhoekA second approach is to directly invoke vnode operations on
2358fae3551SRodney W. Grimesthe lower layer with the
2368fae3551SRodney W. Grimes.Em VOP_OPERATIONNAME
2378fae3551SRodney W. Grimesinterface.
2388fae3551SRodney W. GrimesThe advantage of this method is that it is easy to invoke
2399806e231SRuslan Ermilovarbitrary operations on the lower layer.
2409806e231SRuslan ErmilovThe disadvantage
241f88b745fSTim Vanderhoekis that vnode arguments must be manually mapped.
2428fae3551SRodney W. Grimes.\"
2438fae3551SRodney W. Grimes.\"
2448fae3551SRodney W. Grimes.Sh SEE ALSO
2458fae3551SRodney W. Grimes.Xr mount 8
246726b61abSRuslan Ermilov.Pp
2478fae3551SRodney W. GrimesUCLA Technical Report CSD-910056,
2488fae3551SRodney W. Grimes.Em "Stackable Layers: an Architecture for File System Development" .
2496087df9eSRuslan Ermilov.Sh HISTORY
2506087df9eSRuslan ErmilovThe
251e8533061SSevan Janiyan.Nm mount_null
2526087df9eSRuslan Ermilovutility first appeared in
2536087df9eSRuslan Ermilov.Bx 4.4 .
254e8533061SSevan JaniyanIt was renamed to
255e8533061SSevan Janiyan.Nm
256e8533061SSevan Janiyanin
257e8533061SSevan Janiyan.Fx 5.0 .
258