Remove advertising header from man pages.
[dragonfly.git] / sbin / mount_null / mount_null.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 .\" 4. 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 .\"     @(#)mount_null.8        8.6 (Berkeley) 5/1/95
34 .\" $FreeBSD: src/sbin/mount_null/mount_null.8,v 1.11.2.6 2001/12/20 16:40:00 ru Exp $
35 .\" $DragonFly: src/sbin/mount_null/mount_null.8,v 1.8 2008/10/26 00:05:24 swildner Exp $
36 .\"
37 .Dd September 28, 2008
38 .Dt MOUNT_NULL 8
39 .Os
40 .Sh NAME
41 .Nm mount_null
42 .Nd "mount a loopback filesystem sub-tree; demonstrate the use of a null file system layer"
43 .Sh SYNOPSIS
44 .Nm
45 .Op Fl o Ar options
46 .Ar target
47 .Ar mount-point
48 .Nm
49 .Fl u
50 .Op Fl o Ar options
51 .Ar mount-point
52 .Sh DESCRIPTION
53 The
54 .Nm
55 command creates a
56 null layer, duplicating a sub-tree of the file system
57 name space under another part of the global file system namespace.
58 This allows existing files and directories to be accessed
59 using a different pathname.
60 .Pp
61 The primary differences between a virtual copy of the filesystem
62 and a symbolic link are that the
63 .Xr getcwd 3
64 functions work correctly in the virtual copy, and that other filesystems
65 may be mounted on the virtual copy without affecting the original.
66 A different device number for the virtual copy is returned by
67 .Xr stat 2 ,
68 but in other respects it is indistinguishable from the original.
69 .Pp
70 The
71 .Nm null
72 filesystem differs from a traditional
73 loopback file system in two respects: it is implemented using
74 a stackable layers techniques, and its
75 .Do null-node Dc Ns s
76 stack above
77 all lower-layer vnodes, not just over directory vnodes.
78 .Pp
79 The options are as follows:
80 .Bl -tag -width indent
81 .It Fl o
82 Options are specified with a
83 .Fl o
84 flag followed by a comma separated string of options.
85 See the
86 .Xr mount 8
87 man page for possible options and their meanings.
88 .It Fl u
89 Update the mount point.
90 This is typically used to upgrade a mount to
91 read-write or downgrade it to read-only.
92 .El
93 .Pp
94 The null layer has three purposes.
95 First, it serves as a demonstration of layering by providing a layer
96 which does nothing.
97 (It actually does everything the loopback file system does,
98 which is slightly more than nothing.)
99 Second, it is used for NFS exporting
100 .Nm HAMMER
101 PFSs.
102 Third, the null layer can serve as a prototype layer.
103 Since it provides all necessary layer framework,
104 new file system layers can be created very easily by starting
105 with a null layer.
106 .Pp
107 The remainder of this man page examines the null layer as a basis
108 for constructing new layers.
109 .\"
110 .\"
111 .Sh INSTANTIATING NEW NULL LAYERS
112 New null layers are created with
113 .Nm .
114 .Nm Mount_null
115 takes two arguments, the pathname
116 of the lower vfs (target-pn) and the pathname where the null
117 layer will appear in the namespace (mount-point-pn).  After
118 the null layer is put into place, the contents
119 of target-pn subtree will be aliased under mount-point-pn.
120 .\"
121 .\"
122 .Sh OPERATION OF A NULL LAYER
123 The null layer is the minimum file system layer,
124 simply bypassing all possible operations to the lower layer
125 for processing there.  The majority of its activity centers
126 on the bypass routine, through which nearly all vnode operations
127 pass.
128 .Pp
129 The bypass routine accepts arbitrary vnode operations for
130 handling by the lower layer.  It begins by examining vnode
131 operation arguments and replacing any null-nodes by their
132 lower-layer equivalents.  It then invokes the operation
133 on the lower layer.  Finally, it replaces the null-nodes
134 in the arguments and, if a vnode is returned by the operation,
135 stacks a null-node on top of the returned vnode.
136 .Pp
137 Although bypass handles most operations,
138 .Em vop_getattr ,
139 .Em vop_inactive ,
140 .Em vop_reclaim ,
141 and
142 .Em vop_print
143 are not bypassed.
144 .Em Vop_getattr
145 must change the fsid being returned.
146 .Em Vop_inactive
147 and
148 .Em vop_reclaim
149 are not bypassed so that
150 they can handle freeing null-layer specific data.
151 .Em Vop_print
152 is not bypassed to avoid excessive debugging
153 information.
154 .\"
155 .\"
156 .Sh INSTANTIATING VNODE STACKS
157 Mounting associates the null layer with a lower layer,
158 in effect stacking two VFSes.  Vnode stacks are instead
159 created on demand as files are accessed.
160 .Pp
161 The initial mount creates a single vnode stack for the
162 root of the new null layer.  All other vnode stacks
163 are created as a result of vnode operations on
164 this or other null vnode stacks.
165 .Pp
166 New vnode stacks come into existence as a result of
167 an operation which returns a vnode.
168 The bypass routine stacks a null-node above the new
169 vnode before returning it to the caller.
170 .Pp
171 For example, imagine mounting a null layer with
172 .Bd -literal -offset indent
173 mount_null /usr/include /dev/layer/null
174 .Ed
175 .Pp
176 Changing directory to
177 .Pa /dev/layer/null
178 will assign
179 the root null-node (which was created when the null layer was mounted).
180 Now consider opening
181 .Pa sys .
182 A
183 .Em vop_lookup
184 would be
185 done on the root null-node.  This operation would bypass through
186 to the lower layer which would return a vnode representing
187 the
188 .Xr UFS 5
189 .Pa sys
190 (assuming that the lower layer is an
191 .Xr UFS 5
192 file system).
193 Null_bypass then builds a null-node
194 aliasing the
195 .Xr UFS 5
196 .Pa sys
197 and returns this to the caller.
198 Later operations on the null-node
199 .Pa sys
200 will repeat this
201 process when constructing other vnode stacks.
202 .\"
203 .\"
204 .Sh CREATING OTHER FILE SYSTEM LAYERS
205 One of the easiest ways to construct new file system layers is to make
206 a copy of the null layer, rename all files and variables, and
207 then begin modifying the copy.
208 .Xr Sed 1
209 can be used to easily rename
210 all variables.
211 .\"
212 .\"
213 .Sh INVOKING OPERATIONS ON LOWER LAYERS
214 There are two techniques to invoke operations on a lower layer
215 when the operation cannot be completely bypassed.  Each method
216 is appropriate in different situations.  In both cases,
217 it is the responsibility of the aliasing layer to make
218 the operation arguments "correct" for the lower layer
219 by mapping a vnode argument to the lower layer.
220 .Pp
221 The first approach is to call the aliasing layer's bypass routine.
222 This method is most suitable when you wish to invoke the operation
223 currently being handled on the lower layer.
224 It has the advantage that
225 the bypass routine already must do argument mapping.
226 An example of this is
227 .Em null_getattrs
228 in the null layer.
229 .Pp
230 A second approach is to directly invoke vnode operations on
231 the lower layer with the
232 .Em VOP_OPERATIONNAME
233 interface.
234 The advantage of this method is that it is easy to invoke
235 arbitrary operations on the lower layer.  The disadvantage
236 is that vnode arguments must be manually mapped.
237 .\"
238 .\"
239 .Sh SEE ALSO
240 .Xr HAMMER 5 ,
241 .Xr mount 8
242 .Pp
243 UCLA Technical Report CSD-910056,
244 .Em "Stackable Layers: an Architecture for File System Development" .
245 .Sh HISTORY
246 The
247 .Nm
248 utility first appeared in
249 .Bx 4.4 .
250 .An Matthew Dillon
251 made
252 .Nm
253 work in
254 .Dx 1.7 ,
255 after it had been broken for some time.