]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/mount_nullfs/mount_nullfs.8
Support ARP for 802 networks
[FreeBSD/FreeBSD.git] / sbin / mount_nullfs / mount_nullfs.8
1 .\"
2 .\" Copyright (c) 1992, 1993, 1994
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" This code is derived from software donated to Berkeley by
6 .\" John Heidemann of the UCLA Ficus project.
7 .\"
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\"    may be used to endorse or promote products derived from this software
19 .\"    without specific prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\"
33 .Dd March 24, 2024
34 .Dt MOUNT_NULLFS 8
35 .Os
36 .Sh NAME
37 .Nm mount_nullfs
38 .Nd "mount a loopback file system sub-tree; demonstrate the use of a null file system layer"
39 .Sh SYNOPSIS
40 .Nm
41 .Op Fl o Ar options
42 .Ar target
43 .Ar mount-point
44 .Sh DESCRIPTION
45 The
46 .Nm
47 utility creates a
48 .Xr nullfs 5
49 layer, duplicating a sub-tree of the file system
50 name space under another part of the global file system namespace.
51 This allows existing files and directories to be accessed
52 using a different pathname.
53 .Pp
54 The primary differences between a virtual copy of the file system
55 and a symbolic link are that the
56 .Xr getcwd 3
57 functions work correctly in the virtual copy, and that other file systems
58 may be mounted on the virtual copy without affecting the original.
59 A different device number for the virtual copy is returned by
60 .Xr stat 2 ,
61 but in other respects it is indistinguishable from the original.
62 .Pp
63 The
64 .Nm
65 utility supports mounting both directories and single files.
66 Both
67 .Ar target
68 and
69 .Ar mount_point
70 must be the same type.
71 Mounting directories to files or files to
72 directories is not supported.
73 .Pp
74 The
75 .Nm
76 file system differs from a traditional
77 loopback file system in two respects: it is implemented using
78 a stackable layers techniques, and its
79 .Do null-node Dc Ns s
80 stack above
81 all lower-layer vnodes, not just over directory vnodes.
82 .Pp
83 The options are as follows:
84 .Bl -tag -width indent
85 .It Fl o
86 Options are specified with a
87 .Fl o
88 flag followed by a comma separated string of options.
89 See the
90 .Xr mount 8
91 man page for possible options and their meanings.
92 Additionally the following option is supported:
93 .Bl -tag -width nocache
94 .It Cm nocache
95 Disable metadata caching in the null layer.
96 Some lower-layer file systems may force this option.
97 Depending on the access pattern,
98 this may result in increased lock contention.
99 .It Cm cache
100 Force enable metadata caching.
101 .El
102 .El
103 .Pp
104 The
105 .Dv vfs.nullfs.cache_vnodes
106 sysctl specifies global default for mount-specific cache/nocache option.
107 .Pp
108 The null layer has two purposes.
109 First, it serves as a demonstration of layering by providing a layer
110 which does nothing.
111 (It actually does everything the loopback file system does,
112 which is slightly more than nothing.)
113 Second, the null layer can serve as a prototype layer.
114 Since it provides all necessary layer framework,
115 new file system layers can be created very easily by starting
116 with a null layer.
117 .Pp
118 The remainder of this man page examines the null layer as a basis
119 for constructing new layers.
120 .\"
121 .\"
122 .Sh INSTANTIATING NEW NULL LAYERS
123 New null layers are created with
124 .Nm .
125 The
126 .Nm
127 utility takes two arguments, the pathname
128 of the lower vfs (target-pn) and the pathname where the null
129 layer will appear in the namespace (mount-point-pn).
130 After
131 the null layer is put into place, the contents
132 of target-pn subtree will be aliased under mount-point-pn.
133 .\"
134 .\"
135 .Sh OPERATION OF A NULL LAYER
136 The null layer is the minimum file system layer,
137 simply bypassing all possible operations to the lower layer
138 for processing there.
139 The majority of its activity centers
140 on the bypass routine, through which nearly all vnode operations
141 pass.
142 .Pp
143 The bypass routine accepts arbitrary vnode operations for
144 handling by the lower layer.
145 It begins by examining vnode
146 operation arguments and replacing any null-nodes by their
147 lower-layer equivalents.
148 It then invokes the operation
149 on the lower layer.
150 Finally, it replaces the null-nodes
151 in the arguments and, if a vnode is returned by the operation,
152 stacks a null-node on top of the returned vnode.
153 .Pp
154 Although bypass handles most operations,
155 .Em vop_getattr ,
156 .Em vop_inactive ,
157 .Em vop_reclaim ,
158 and
159 .Em vop_print
160 are not bypassed.
161 .Em Vop_getattr
162 must change the fsid being returned.
163 .Em Vop_inactive
164 and
165 .Em vop_reclaim
166 are not bypassed so that
167 they can handle freeing null-layer specific data.
168 .Em Vop_print
169 is not bypassed to avoid excessive debugging
170 information.
171 .\"
172 .\"
173 .Sh INSTANTIATING VNODE STACKS
174 Mounting associates the null layer with a lower layer,
175 in effect stacking two VFSes.
176 Vnode stacks are instead
177 created on demand as files are accessed.
178 .Pp
179 The initial mount creates a single vnode stack for the
180 root of the new null layer.
181 All other vnode stacks
182 are created as a result of vnode operations on
183 this or other null vnode stacks.
184 .Pp
185 New vnode stacks come into existence as a result of
186 an operation which returns a vnode.
187 The bypass routine stacks a null-node above the new
188 vnode before returning it to the caller.
189 .Pp
190 For example, imagine mounting a null layer with
191 .Bd -literal -offset indent
192 mount_nullfs /usr/include /dev/layer/null
193 .Ed
194 .Pp
195 Changing directory to
196 .Pa /dev/layer/null
197 will assign
198 the root null-node (which was created when the null layer was mounted).
199 Now consider opening
200 .Pa sys .
201 A vop_lookup would be
202 done on the root null-node.
203 This operation would bypass through
204 to the lower layer which would return a vnode representing
205 the UFS
206 .Pa sys .
207 Null_bypass then builds a null-node
208 aliasing the UFS
209 .Pa sys
210 and returns this to the caller.
211 Later operations on the null-node
212 .Pa sys
213 will repeat this
214 process when constructing other vnode stacks.
215 .\"
216 .\"
217 .Sh CREATING OTHER FILE SYSTEM LAYERS
218 One of the easiest ways to construct new file system layers is to make
219 a copy of the null layer, rename all files and variables, and
220 then begin modifying the copy.
221 The
222 .Xr sed 1
223 utility can be used to easily rename
224 all variables.
225 .Pp
226 The umap layer is an example of a layer descended from the
227 null layer.
228 .\"
229 .\"
230 .Sh INVOKING OPERATIONS ON LOWER LAYERS
231 There are two techniques to invoke operations on a lower layer
232 when the operation cannot be completely bypassed.
233 Each method
234 is appropriate in different situations.
235 In both cases,
236 it is the responsibility of the aliasing layer to make
237 the operation arguments "correct" for the lower layer
238 by mapping a vnode argument to the lower layer.
239 .Pp
240 The first approach is to call the aliasing layer's bypass routine.
241 This method is most suitable when you wish to invoke the operation
242 currently being handled on the lower layer.
243 It has the advantage that
244 the bypass routine already must do argument mapping.
245 An example of this is
246 .Em null_getattrs
247 in the null layer.
248 .Pp
249 A second approach is to directly invoke vnode operations on
250 the lower layer with the
251 .Em VOP_OPERATIONNAME
252 interface.
253 The advantage of this method is that it is easy to invoke
254 arbitrary operations on the lower layer.
255 The disadvantage
256 is that vnode arguments must be manually mapped.
257 .\"
258 .\"
259 .Sh SEE ALSO
260 .Xr nullfs 5 ,
261 .Xr mount 8
262 .Pp
263 UCLA Technical Report CSD-910056,
264 .Em "Stackable Layers: an Architecture for File System Development" .
265 .Sh HISTORY
266 The
267 .Nm mount_null
268 utility first appeared in
269 .Bx 4.4 .
270 It was renamed to
271 .Nm
272 in
273 .Fx 5.0 .