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