Use .Va for sysctls and tunables.
[dragonfly.git] / sbin / mount_union / mount_union.8
1 .\" Copyright (c) 1994
2 .\" The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software donated to Berkeley by
5 .\" Jan-Simon Pendry.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)mount_union.8       8.6 (Berkeley) 3/27/94
36 .\" $FreeBSD: src/sbin/mount_union/mount_union.8,v 1.6.2.2 2001/12/20 16:46:05 ru Exp $
37 .\" $DragonFly: src/sbin/mount_union/mount_union.8,v 1.6 2007/07/14 21:48:16 swildner Exp $
38 .\"
39 .Dd March 27, 1994
40 .Dt MOUNT_UNION 8
41 .Os
42 .Sh NAME
43 .Nm mount_union
44 .Nd mount union filesystems
45 .Sh SYNOPSIS
46 .Nm
47 .Op Fl br
48 .Op Fl o Ar options
49 .Ar directory
50 .Ar uniondir
51 .Sh DESCRIPTION
52 The
53 .Nm
54 command
55 attaches
56 .Ar directory
57 above
58 .Ar uniondir
59 in such a way that the contents of both directory trees remain visible.
60 By default,
61 .Ar directory
62 becomes the
63 .Em upper
64 layer and
65 .Ar uniondir
66 becomes the
67 .Em lower
68 layer.
69 .Pp
70 The options are as follows:
71 .Bl -tag -width indent
72 .It Fl b
73 Invert the default position, so that
74 .Ar directory
75 becomes the lower layer and
76 .Ar uniondir
77 becomes the upper layer.
78 However,
79 .Ar uniondir
80 remains the mount point.
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 r
89 Hide the lower layer completely in the same way as mounting with
90 .Xr mount_null 8 .
91 .El
92 .Pp
93 To enforce filesystem security, the user mounting the filesystem
94 must be superuser or else have write permission on the mounted-on
95 directory.
96 In addition, the
97 .Va vfs.usermount
98 .Xr sysctl 3
99 variable must be set to 1 to permit file system mounting by ordinary users.
100 .Pp
101 Filenames are looked up in the upper layer and then in the
102 lower layer.
103 If a directory is found in the lower layer, and there is no entry
104 in the upper layer, then a
105 .Em shadow
106 directory will be created in the upper layer.
107 It will be owned by the user who originally did the union mount,
108 with mode
109 .Dq rwxrwxrwx
110 (0777) modified by the umask in effect at that time.
111 .Pp
112 If a file exists in the upper layer then there is no way to access
113 a file with the same name in the lower layer.
114 If necessary, a combination of loopback and union mounts can be made
115 which will still allow the lower files to be accessed by a different
116 pathname.
117 .Pp
118 Except in the case of a directory,
119 access to an object is granted via the normal filesystem access checks.
120 For directories, the current user must have access to both the upper
121 and lower directories (should they both exist).
122 .Pp
123 Requests to create or modify objects in
124 .Ar uniondir
125 are passed to the upper layer with the exception of a few special cases.
126 An attempt to open for writing a file which exists in the lower layer
127 causes a copy of the
128 .Em entire
129 file to be made to the upper layer, and then for the upper layer copy
130 to be opened.
131 Similarly, an attempt to truncate a lower layer file to zero length
132 causes an empty file to be created in the upper layer.
133 Any other operation which would ultimately require modification to
134 the lower layer fails with
135 .Er EROFS .
136 .Pp
137 The union filesystem manipulates the namespace, rather than
138 individual filesystems.
139 The union operation applies recursively down the directory tree
140 now rooted at
141 .Ar uniondir .
142 Thus any filesystems which are mounted under
143 .Ar uniondir
144 will take part in the union operation.
145 This differs from the
146 .Em union
147 option to
148 .Xr mount 8
149 which only applies the union operation to the mount point itself,
150 and then only for lookups.
151 .Sh EXAMPLES
152 The commands
153 .Bd -literal -offset indent
154 mount -t cd9660 -o ro /dev/cd0a /usr/src
155 mount -t union /var/obj /usr/src
156 .Ed
157 .Pp
158 mount the CD-ROM drive
159 .Pa /dev/cd0a
160 on
161 .Pa /usr/src
162 and then attaches
163 .Pa /var/obj
164 on top.
165 For most purposes the effect of this is to make the
166 source tree appear writable
167 even though it is stored on a CD-ROM.
168 .Pp
169 The command
170 .Bd -literal -offset indent
171 mount -t union -o -b /sys $HOME/sys
172 .Ed
173 .Pp
174 attaches the system source tree below the
175 .Pa sys
176 directory in the user's home directory.
177 This allows individual users to make private changes
178 to the source, and build new kernels, without those
179 changes becoming visible to other users.
180 Note that the files in the lower layer remain
181 accessible via
182 .Pa /sys .
183 .Sh SEE ALSO
184 .Xr intro 2 ,
185 .Xr mount 2 ,
186 .Xr unmount 2 ,
187 .Xr fstab 5 ,
188 .Xr mount 8 ,
189 .Xr mount_null 8
190 .Sh HISTORY
191 The
192 .Nm
193 command first appeared in
194 .Bx 4.4 .
195 It first worked in
196 .Fx Ns -(fill this in) .
197 .Sh BUGS
198 THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
199 AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM.  USE AT YOUR
200 OWN RISK.  BEWARE OF DOG.  SLIPPERY WHEN WET.
201 .Pp
202 This code also needs an owner in order to be less dangerous - serious
203 hackers can apply by sending mail to
204 .Aq kernel@crater.dragonflybsd.org
205 and announcing
206 their intent to take it over.
207 .Pp
208 Without whiteout support from the filesystem backing the upper layer,
209 there is no way that delete and rename operations on lower layer
210 objects can be done.
211 .Er EROFS
212 is returned for this kind of operations along with any others
213 which would make modifications to the lower layer, such as
214 .Xr chmod 1 .
215 .Pp
216 Running
217 .Xr find 1
218 over a union tree has the side-effect of creating
219 a tree of shadow directories in the upper layer.