]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - lib/libc/sys/mount.2
Change the current working directory to be inside the jail created by
[FreeBSD/releng/7.2.git] / lib / libc / sys / mount.2
1 .\" Copyright (c) 1980, 1989, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)mount.2     8.3 (Berkeley) 5/24/95
29 .\" $FreeBSD$
30 .\"
31 .Dd February 23, 2005
32 .Dt MOUNT 2
33 .Os
34 .Sh NAME
35 .Nm mount ,
36 .Nm nmount ,
37 .Nm unmount
38 .Nd mount or dismount a file system
39 .Sh LIBRARY
40 .Lb libc
41 .Sh SYNOPSIS
42 .In sys/param.h
43 .In sys/mount.h
44 .Ft int
45 .Fn mount "const char *type" "const char *dir" "int flags" "void *data"
46 .Ft int
47 .Fn unmount "const char *dir" "int flags"
48 .In sys/uio.h
49 .Ft int
50 .Fn nmount "struct iovec *iov" "u_int niov" "int flags"
51 .Sh DESCRIPTION
52 The
53 .Fn mount
54 system call grafts
55 a file system object onto the system file tree
56 at the point
57 .Fa dir .
58 The argument
59 .Fa data
60 describes the file system object to be mounted.
61 The argument
62 .Fa type
63 tells the kernel how to interpret
64 .Fa data
65 (See
66 .Fa type
67 below).
68 The contents of the file system
69 become available through the new mount point
70 .Fa dir .
71 Any files in
72 .Fa dir
73 at the time
74 of a successful mount are swept under the carpet so to speak, and
75 are unavailable until the file system is unmounted.
76 .Pp
77 The
78 .Fn nmount
79 system call behaves similarly to
80 .Fn mount ,
81 except that the mount options (file system type name, device to mount,
82 mount-point name, etc.) are passed as an array of name-value pairs
83 in the array
84 .Fa iov ,
85 containing
86 .Fa niov
87 elements.
88 The following options are required by all file systems:
89 .Bl -item -offset indent -compact
90 .It
91 .Li fstype Ta file system type name (e.g., Dq Li procfs )
92 .It
93 .Li fspath Ta mount point pathname (e.g., Dq Li /proc )
94 .El
95 .Pp
96 Depending on the file system type, other options may be
97 recognized or required;
98 for example, most disk-based file systems require a
99 .Dq Li from
100 option containing the pathname of a special device
101 in addition to the options listed above.
102 .Pp
103 By default only the super-user may call the
104 .Fn mount
105 system call.
106 This restriction can be removed by setting the
107 .Va vfs.usermount
108 .Xr sysctl 8
109 variable
110 to a non-zero value; see the BUGS section for more information.
111 .Pp
112 The following
113 .Fa flags
114 may be specified to
115 suppress default semantics which affect file system access.
116 .Bl -tag -width MNT_SYNCHRONOUS
117 .It Dv MNT_RDONLY
118 The file system should be treated as read-only;
119 even the super-user may not write on it.
120 Specifying MNT_UPDATE without this option will upgrade
121 a read-only file system to read/write.
122 .It Dv MNT_NOEXEC
123 Do not allow files to be executed from the file system.
124 .It Dv MNT_NOSUID
125 Do not honor setuid or setgid bits on files when executing them.
126 This flag is set automatically when the caller is not the super-user.
127 .It Dv MNT_NOATIME
128 Disable update of file access times.
129 .It Dv MNT_SNAPSHOT
130 Create a snapshot of the file system.
131 This is currently only supported on UFS2 file systems, see
132 .Xr mksnap_ffs 8
133 for more information.
134 .It Dv MNT_SUIDDIR
135 Directories with the SUID bit set chown new files to their own owner.
136 This flag requires the SUIDDIR option to have been compiled into the kernel
137 to have any effect.
138 See the
139 .Xr mount 8
140 and
141 .Xr chmod 2
142 pages for more information.
143 .It Dv MNT_SYNCHRONOUS
144 All I/O to the file system should be done synchronously.
145 .It Dv MNT_ASYNC
146 All I/O to the file system should be done asynchronously.
147 .It Dv MNT_FORCE
148 Force a read-write mount even if the file system appears to be unclean.
149 Dangerous.
150 Together with
151 .Dv MNT_UPDATE
152 and
153 .Dv MNT_RDONLY ,
154 specify that the file system is to be forcibly downgraded to a read-only
155 mount even if some files are open for writing.
156 .It Dv MNT_NOCLUSTERR
157 Disable read clustering.
158 .It Dv MNT_NOCLUSTERW
159 Disable write clustering.
160 .El
161 .Pp
162 The flag
163 .Dv MNT_UPDATE
164 indicates that the mount command is being applied
165 to an already mounted file system.
166 This allows the mount flags to be changed without requiring
167 that the file system be unmounted and remounted.
168 Some file systems may not allow all flags to be changed.
169 For example,
170 many file systems will not allow a change from read-write to read-only.
171 .Pp
172 The flag
173 .Dv MNT_RELOAD
174 causes the vfs subsystem to update its data structures pertaining to
175 the specified already mounted file system.
176 .Pp
177 The
178 .Fa type
179 argument names the file system.
180 The types of file systems known to the system can be obtained with
181 .Xr lsvfs 1 .
182 .Pp
183 The
184 .Fa data
185 argument
186 is a pointer to a structure that contains the type
187 specific arguments to mount.
188 The format for these argument structures is described in the
189 manual page for each file system.
190 By convention file system manual pages are named
191 by prefixing ``mount_'' to the name of the file system as returned by
192 .Xr lsvfs 1 .
193 Thus the
194 .Tn NFS
195 file system is described by the
196 .Xr mount_nfs 8
197 manual page.
198 It should be noted that a manual page for default
199 file systems, known as UFS and UFS2, does not exist.
200 .Pp
201 The
202 .Fn unmount
203 system call disassociates the file system from the specified
204 mount point
205 .Fa dir .
206 .Pp
207 The
208 .Fa flags
209 argument may include
210 .Dv MNT_FORCE
211 to specify that the file system should be forcibly unmounted
212 even if files are still active.
213 Active special devices continue to work,
214 but any further accesses to any other active files result in errors
215 even if the file system is later remounted.
216 .Pp
217 If the
218 .Dv MNT_BYFSID
219 flag is specified,
220 .Fa dir
221 should instead be a file system ID encoded as
222 .Dq Li FSID : Ns Ar val0 : Ns Ar val1 ,
223 where
224 .Ar val0
225 and
226 .Ar val1
227 are the contents of the
228 .Vt fsid_t
229 .Va val[]
230 array in decimal.
231 The file system that has the specified file system ID will be unmounted.
232 .Sh RETURN VALUES
233 .Rv -std
234 .Sh ERRORS
235 The
236 .Fn mount
237 and
238 .Fn nmount
239 system calls will fail when one of the following occurs:
240 .Bl -tag -width Er
241 .It Bq Er EPERM
242 The caller is neither the super-user nor the owner of
243 .Fa dir .
244 .It Bq Er ENAMETOOLONG
245 A component of a pathname exceeded 255 characters,
246 or the entire length of a path name exceeded 1023 characters.
247 .It Bq Er ELOOP
248 Too many symbolic links were encountered in translating a pathname.
249 .It Bq Er ENOENT
250 A component of
251 .Fa dir
252 does not exist.
253 .It Bq Er ENOTDIR
254 A component of
255 .Fa name
256 is not a directory,
257 or a path prefix of
258 .Fa special
259 is not a directory.
260 .It Bq Er EBUSY
261 Another process currently holds a reference to
262 .Fa dir .
263 .It Bq Er EFAULT
264 The
265 .Fa dir
266 argument
267 points outside the process's allocated address space.
268 .El
269 .Pp
270 The following errors can occur for a
271 .Em ufs
272 file system mount:
273 .Bl -tag -width Er
274 .It Bq Er ENODEV
275 A component of ufs_args
276 .Fa fspec
277 does not exist.
278 .It Bq Er ENOTBLK
279 The
280 .Fa fspec
281 argument
282 is not a block device.
283 .It Bq Er ENXIO
284 The major device number of
285 .Fa fspec
286 is out of range (this indicates no device driver exists
287 for the associated hardware).
288 .It Bq Er EBUSY
289 .Fa fspec
290 is already mounted.
291 .It Bq Er EMFILE
292 No space remains in the mount table.
293 .It Bq Er EINVAL
294 The super block for the file system had a bad magic
295 number or an out of range block size.
296 .It Bq Er ENOMEM
297 Not enough memory was available to read the cylinder
298 group information for the file system.
299 .It Bq Er EIO
300 An I/O error occurred while reading the super block or
301 cylinder group information.
302 .It Bq Er EFAULT
303 The
304 .Fa fspec
305 argument
306 points outside the process's allocated address space.
307 .El
308 .Pp
309 The following errors can occur for a
310 .Em nfs
311 file system mount:
312 .Bl -tag -width Er
313 .It Bq Er ETIMEDOUT
314 .Em Nfs
315 timed out trying to contact the server.
316 .It Bq Er EFAULT
317 Some part of the information described by nfs_args
318 points outside the process's allocated address space.
319 .El
320 .Pp
321 The
322 .Fn unmount
323 system call may fail with one of the following errors:
324 .Bl -tag -width Er
325 .It Bq Er EPERM
326 The caller is neither the super-user nor the user who issued the corresponding
327 .Fn mount
328 call.
329 .It Bq Er ENAMETOOLONG
330 The length of the path name exceeded 1023 characters.
331 .It Bq Er EINVAL
332 The requested directory is not in the mount table.
333 .It Bq Er ENOENT
334 The file system ID specified using
335 .Dv MNT_BYFSID
336 was not found in the mount table.
337 .It Bq Er EINVAL
338 The file system ID specified using
339 .Dv MNT_BYFSID
340 could not be decoded.
341 .It Bq Er EINVAL
342 The specified file system is the root file system.
343 .It Bq Er EBUSY
344 A process is holding a reference to a file located
345 on the file system.
346 .It Bq Er EIO
347 An I/O error occurred while writing cached file system information.
348 .It Bq Er EFAULT
349 The
350 .Fa dir
351 argument
352 points outside the process's allocated address space.
353 .El
354 .Pp
355 A
356 .Em ufs
357 mount can also fail if the maximum number of file systems are currently
358 mounted.
359 .Sh SEE ALSO
360 .Xr lsvfs 1 ,
361 .Xr mksnap_ffs 8 ,
362 .Xr mount 8 ,
363 .Xr umount 8
364 .Sh HISTORY
365 The
366 .Fn mount
367 and
368 .Fn unmount
369 functions appeared in
370 .At v6 .
371 .Sh BUGS
372 Some of the error codes need translation to more obvious messages.
373 .Pp
374 Allowing untrusted users to mount arbitrary media, e.g. by enabling
375 .Va vfs.usermount ,
376 should not be considered safe.
377 Most file systems in
378 .Fx
379 were not built to safeguard against malicious devices.