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