📄 mount_null.8
字号:
.\".\" Copyright (c) 1992, 1993, 1994.\" The Regents of the University of California. All rights reserved..\".\" This code is derived from software donated to Berkeley by.\" John Heidemann of the UCLA Ficus project..\".\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)mount_null.8 8.4 (Berkeley) 4/19/94.\".\".Dd April 19, 1994.Dt MOUNT_NULL 8.Os BSD 4.4.Sh NAME.Nm mount_null.Nd demonstrate the use of a null file system layer.Sh SYNOPSIS.Nm mount_null.Op Fl o Ar options.Ar target.Ar mount-point.Sh DESCRIPTIONThe.Nm mount_nullcommand creates anull layer, duplicating a sub-tree of the file systemname space under another part of the global file system namespace.In this respect, it issimilar to the loopback file system (see.Xr mount_lofs 8 ) .It differs fromthe loopback file system in two respects: it is implemented usinga stackable layers techniques, and it's .Donull-node.Dc sstack aboveall lower-layer vnodes, not just over directory vnodes..PpThe options are as follows:.Bl -tag -width indent.It Fl oOptions are specified with a.Fl oflag followed by a comma separated string of options.See the.Xr mount 8man page for possible options and their meanings..El.PpThe null layer has two purposes.First, it serves as a demonstration of layering by proving a layerwhich does nothing.(It actually does everything the loopback file system does,which is slightly more than nothing.)Second, the null layer can serve as a prototype layer.Since it provides all necessary layer framework,new file system layers can be created very easily be startingwith a null layer..PpThe remainder of this man page examines the null layer as a basisfor constructing new layers..\".\".Sh INSTANTIATING NEW NULL LAYERSNew null layers are created with .Xr mount_null 8 ..Xr Mount_null 8takes two arguments, the pathnameof the lower vfs (target-pn) and the pathname where the nulllayer will appear in the namespace (mount-point-pn). Afterthe null layer is put into place, the contentsof target-pn subtree will be aliased under mount-point-pn..\".\".Sh OPERATION OF A NULL LAYERThe null layer is the minimum file system layer,simply bypassing all possible operations to the lower layerfor processing there. The majority of its activity centerson the bypass routine, though which nearly all vnode operationspass..PpThe bypass routine accepts arbitrary vnode operations forhandling by the lower layer. It begins by examing vnodeoperation arguments and replacing any null-nodes by theirlower-layer equivalents. It then invokes the operationon the lower layer. Finally, it replaces the null-nodesin the arguments and, if a vnode is returned by the operation,stacks a null-node on top of the returned vnode..PpAlthough bypass handles most operations, .Em vop_getattr , .Em vop_inactive ,.Em vop_reclaim ,and.Em vop_printare not bypassed..Em Vop_getattrmust change the fsid being returned..Em Vop_inactiveand vop_reclaim are not bypassed so thatthey can handle freeing null-layer specific data..Em Vop_printis not bypassed to avoid excessive debugginginformation..\".\".Sh INSTANTIATING VNODE STACKSMounting associates the null layer with a lower layer,in effect stacking two VFSes. Vnode stacks are insteadcreated on demand as files are accessed..PpThe initial mount creates a single vnode stack for theroot of the new null layer. All other vnode stacksare created as a result of vnode operations onthis or other null vnode stacks..PpNew vnode stacks come into existence as a result ofan operation which returns a vnode. The bypass routine stacks a null-node above the newvnode before returning it to the caller..PpFor example, imagine mounting a null layer with.Bd -literal -offset indentmount_null /usr/include /dev/layer/null.EdChanging directory to .Pa /dev/layer/nullwill assignthe root null-node (which was created when the null layer was mounted).Now consider opening .Pa sys .A vop_lookup would bedone on the root null-node. This operation would bypass throughto the lower layer which would return a vnode representing the UFS .Pa sys .Null_bypass then builds a null-nodealiasing the UFS .Pa sysand returns this to the caller.Later operations on the null-node .Pa syswill repeat this process when constructing other vnode stacks..\".\".Sh CREATING OTHER FILE SYSTEM LAYERSOne of the easiest ways to construct new file system layers is to makea copy of the null layer, rename all files and variables, andthen begin modifyng the copy. Sed can be used to easily renameall variables..PpThe umap layer is an example of a layer descended from the null layer..\".\".Sh INVOKING OPERATIONS ON LOWER LAYERSThere are two techniques to invoke operations on a lower layer when the operation cannot be completely bypassed. Each methodis appropriate in different situations. In both cases,it is the responsibility of the aliasing layer to makethe operation arguments "correct" for the lower layerby mapping an vnode arguments to the lower layer..PpThe first approach is to call the aliasing layer's bypass routine.This method is most suitable when you wish to invoke the operationcurrently being handled on the lower layer. It has the advantagethe the bypass routine already must do argument mapping.An example of this is .Em null_getattrsin the null layer..PpA second approach is to directly invoked vnode operations onthe lower layer with the.Em VOP_OPERATIONNAMEinterface.The advantage of this method is that it is easy to invokearbitrary operations on the lower layer. The disadvantageis that vnodes arguments must be manually mapped..\".\".Sh SEE ALSO.Xr mount 8.spUCLA Technical Report CSD-910056,.Em "Stackable Layers: an Architecture for File System Development" ..Sh HISTORYThe.Nm mount_nullutility first appeared in 4.4BSD.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -