Initial import from FreeBSD RELENG_4:
[dragonfly.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: src/lib/libc/sys/mount.2,v 1.20.2.8 2003/01/17 22:02:42 joerg Exp $
34 .\"
35 .Dd May 24, 1995
36 .Dt MOUNT 2
37 .Os
38 .Sh NAME
39 .Nm mount ,
40 .Nm unmount
41 .Nd mount or dismount a filesystem
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In sys/param.h
46 .In sys/mount.h
47 .Ft int
48 .Fn mount "const char *type" "const char *dir" "int flags" "void *data"
49 .Ft int
50 .Fn unmount "const char *dir" "int flags"
51 .Sh DESCRIPTION
52 The
53 .Fn mount
54 function grafts
55 a filesystem object onto the system file tree
56 at the point
57 .Ar dir .
58 The argument
59 .Ar data
60 describes the filesystem object to be mounted.
61 The argument
62 .Ar type
63 tells the kernel how to interpret
64 .Ar data
65 (See
66 .Ar type
67 below).
68 The contents of the filesystem
69 become available through the new mount point
70 .Ar dir .
71 Any files in
72 .Ar dir
73 at the time
74 of a successful mount are swept under the carpet so to speak, and
75 are unavailable until the filesystem is unmounted.
76 .Pp
77 By default only the super-user may call the
78 .Fn mount
79 function.
80 This restriction can be removed by setting the sysctl
81 .Em vfs.usermount
82 to a non-zero value.
83 .Pp
84 The following
85 .Ar flags
86 may be specified to
87 suppress default semantics which affect filesystem access.
88 .Bl -tag -width MNT_SYNCHRONOUS
89 .It Dv MNT_RDONLY
90 The filesystem should be treated as read-only;
91 Even the super-user may not write on it.
92 Specifying MNT_UPDATE without this option will upgrade
93 a read-only filesystem to read/write.
94 .It Dv MNT_NOEXEC
95 Do not allow files to be executed from the filesystem.
96 .It Dv MNT_NOSUID
97 Do not honor setuid or setgid bits on files when executing them.
98 This flag is set automatically when the caller is not the super-user.
99 .It Dv MNT_NOATIME
100 Disable update of file access times.
101 .It Dv MNT_NODEV
102 Do not interpret special files on the filesystem.
103 This flag is set automatically when the caller is not the super-user.
104 .It Dv MNT_SUIDDIR
105 Directories with the SUID bit set chown new files to their own owner.
106 .It Dv MNT_SYNCHRONOUS
107 All I/O to the filesystem should be done synchronously.
108 .It Dv MNT_ASYNC
109 All I/O to the filesystem should be done asynchronously.
110 .It Dv MNT_FORCE
111 Force a read-write mount even if the filesystem appears to be unclean.
112 Dangerous.
113 .It Dv MNT_NOCLUSTERR
114 Disable read clustering.
115 .It Dv MNT_NOCLUSTERW
116 Disable write clustering.
117 .El
118 .Pp
119 The flag
120 .Dv MNT_UPDATE
121 indicates that the mount command is being applied
122 to an already mounted filesystem.
123 This allows the mount flags to be changed without requiring
124 that the filesystem be unmounted and remounted.
125 Some filesystems may not allow all flags to be changed.
126 For example,
127 many filesystems will not allow a change from read-write to read-only.
128 .Pp
129 The flag
130 .Dv MNT_RELOAD
131 causes the vfs subsystem to update its data structures pertaining to
132 the specified already mounted filesystem.
133 .Pp
134 The
135 .Fa type
136 argument names the filesystem.
137 The types of filesystems known to the system can be obtained with
138 .Xr lsvfs 1 .
139 .Pp
140 .Fa Data
141 is a pointer to a structure that contains the type
142 specific arguments to mount.
143 The format for these argument structures is described in the
144 manual page for each filesystem.
145 By convention filesystem manual pages are named
146 by prefixing ``mount_'' to the name of the filesystem as returned by
147 .Xr lsvfs 1 .
148 Thus the
149 .Nm NFS
150 filesystem is described by the
151 .Xr mount_nfs 8
152 manual page.
153 .Pp
154 The
155 .Fn unmount
156 function call disassociates the filesystem from the specified
157 mount point
158 .Fa dir .
159 .Pp
160 The
161 .Fa flags
162 argument may specify
163 .Dv MNT_FORCE
164 to specify that the filesystem should be forcibly unmounted or made read-only
165 (if MNT_UPDATE and MNT_RDONLY are also specified)
166 even if files are still active.
167 Active special devices continue to work,
168 but any further accesses to any other active files result in errors
169 even if the filesystem is later remounted.
170 .Pp
171 The
172 .Dv MNT_SUIDDIR
173 option requires the SUIDDIR option to have been compiled into the kernel
174 to have any effect.
175 See the
176 .Xr mount 8
177 and
178 .Xr chmod 2
179 pages for more information.
180 .Sh RETURN VALUES
181 .Rv -std
182 .Sh ERRORS
183 The
184 .Fn mount
185 function will fail when one of the following occurs:
186 .Bl -tag -width Er
187 .It Bq Er EPERM
188 The caller is neither the super-user nor the owner of
189 .Ar dir .
190 .It Bq Er ENAMETOOLONG
191 A component of a pathname exceeded 255 characters,
192 or the entire length of a path name exceeded 1023 characters.
193 .It Bq Er ELOOP
194 Too many symbolic links were encountered in translating a pathname.
195 .It Bq Er ENOENT
196 A component of
197 .Fa dir
198 does not exist.
199 .It Bq Er ENOTDIR
200 A component of
201 .Ar name
202 is not a directory,
203 or a path prefix of
204 .Ar special
205 is not a directory.
206 .It Bq Er EBUSY
207 Another process currently holds a reference to
208 .Fa dir .
209 .It Bq Er EFAULT
210 .Fa Dir
211 points outside the process's allocated address space.
212 .El
213 .Pp
214 The following errors can occur for a
215 .Em ufs
216 filesystem mount:
217 .Bl -tag -width Er
218 .It Bq Er ENODEV
219 A component of ufs_args
220 .Ar fspec
221 does not exist.
222 .It Bq Er ENOTBLK
223 .Ar Fspec
224 is not a block device.
225 .It Bq Er ENXIO
226 The major device number of
227 .Ar fspec
228 is out of range (this indicates no device driver exists
229 for the associated hardware).
230 .It Bq Er EBUSY
231 .Ar Fspec
232 is already mounted.
233 .It Bq Er EMFILE
234 No space remains in the mount table.
235 .It Bq Er EINVAL
236 The super block for the filesystem had a bad magic
237 number or an out of range block size.
238 .It Bq Er ENOMEM
239 Not enough memory was available to read the cylinder
240 group information for the filesystem.
241 .It Bq Er EIO
242 An I/O error occurred while reading the super block or
243 cylinder group information.
244 .It Bq Er EFAULT
245 .Ar Fspec
246 points outside the process's allocated address space.
247 .El
248 .Pp
249 The following errors can occur for a
250 .Em nfs
251 filesystem mount:
252 .Bl -tag -width Er
253 .It Bq Er ETIMEDOUT
254 .Em Nfs
255 timed out trying to contact the server.
256 .It Bq Er EFAULT
257 Some part of the information described by nfs_args
258 points outside the process's allocated address space.
259 .El
260 .Pp
261 The following errors can occur for a
262 .Em mfs
263 filesystem mount:
264 .Bl -tag -width Er
265 .It Bq Er EMFILE
266 No space remains in the mount table.
267 .It Bq Er EINVAL
268 The super block for the filesystem had a bad magic
269 number or an out of range block size.
270 .It Bq Er ENOMEM
271 Not enough memory was available to read the cylinder
272 group information for the filesystem.
273 .It Bq Er EIO
274 A paging error occurred while reading the super block or
275 cylinder group information.
276 .It Bq Er EFAULT
277 .Em Name
278 points outside the process's allocated address space.
279 .El
280 .Pp
281 The
282 .Fn unmount
283 function may fail with one of the following errors:
284 .Bl -tag -width Er
285 .It Bq Er EPERM
286 The caller is neither the super-user nor the user who issued the corresponding
287 .Xr mount 2
288 call.
289 .It Bq Er ENOTDIR
290 A component of the path is not a directory.
291 .It Bq Er ENAMETOOLONG
292 A component of a pathname exceeded 255 characters,
293 or an entire path name exceeded 1023 characters.
294 .It Bq Er ELOOP
295 Too many symbolic links were encountered in translating the pathname.
296 .It Bq Er EINVAL
297 The requested directory is not in the mount table.
298 .It Bq Er EBUSY
299 A process is holding a reference to a file located
300 on the filesystem.
301 .It Bq Er EIO
302 An I/O error occurred while writing cached filesystem information.
303 .It Bq Er EFAULT
304 .Fa Dir
305 points outside the process's allocated address space.
306 .El
307 .Pp
308 A
309 .Em ufs
310 or
311 .Em mfs
312 mount can also fail if the maximum number of filesystems are currently
313 mounted.
314 .Sh SEE ALSO
315 .Xr lsvfs 1 ,
316 .Xr mfs 8 ,
317 .Xr mount 8 ,
318 .Xr sysctl 8 ,
319 .Xr umount 8
320 .Sh BUGS
321 Some of the error codes need translation to more obvious messages.
322 .Sh HISTORY
323 .Fn Mount
324 and
325 .Fn unmount
326 function calls appeared in
327 .At v6 .