]> git.saurik.com Git - apple/xnu.git/blob - bsd/man/man2/mount.2
xnu-344.tar.gz
[apple/xnu.git] / bsd / man / man2 / mount.2
1 .\" $OpenBSD: mount.2,v 1.6 1997/03/09 19:41:16 millert Exp $
2 .\" $NetBSD: mount.2,v 1.12 1996/02/29 23:47:48 jtc Exp $
3 .\"
4 .\" Copyright (c) 1980, 1989, 1993
5 .\" The Regents of the University of California. All rights reserved.
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.2 8.2 (Berkeley) 12/11/93
36 .\"
37 .Dd December 11, 1993
38 .Dt MOUNT 2
39 .Os BSD 4
40 .Sh NAME
41 .Nm mount ,
42 .Nm unmount
43 .Nd mount or dismount a filesystem
44 .Sh SYNOPSIS
45 .Fd #include <sys/param.h>
46 .Fd #include <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 The following
78 .Ar flags
79 may be specified to
80 suppress default semantics which affect filesystem access.
81 .Bl -tag -width MNT_SYNCHRONOUS
82 .It Dv MNT_RDONLY
83 The filesystem should be treated as read-only;
84 Even the super-user may not write on it.
85 .It Dv MNT_NOATIME
86 Do not update the access time on files in the filesystem unless
87 the modification or status change times are also being updated.
88 .It Dv MNT_NOEXEC
89 Do not allow files to be executed from the filesystem.
90 .It Dv MNT_NOSUID
91 Do not honor setuid or setgid bits on files when executing them.
92 .It Dv MNT_NODEV
93 Do not interpret special files on the filesystem.
94 .It Dv MNT_UNION
95 Union with underlying filesystem instead of obscuring it.
96 .It Dv MNT_SYNCHRONOUS
97 All I/O to the filesystem should be done synchronously.
98 .El
99 .Pp
100 The flag
101 .Dv MNT_UPDATE
102 indicates that the mount command is being applied
103 to an already mounted filesystem.
104 This allows the mount flags to be changed without requiring
105 that the filesystem be unmounted and remounted.
106 Some filesystems may not allow all flags to be changed.
107 For example,
108 most filesystems will not allow a change from read-write to read-only.
109 .Pp
110 The
111 .Fa type
112 argument defines the type of the filesystem.
113 The types of filesystems known to the system are defined in
114 .Aq Pa sys/mount.h .
115 .Fa Data
116 is a pointer to a structure that contains the type
117 specific arguments to mount.
118 The currently supported types of filesystems and
119 their type specific data are:
120 .Pp
121 .Dv MOUNT_FFS
122 .Bd -literal -offset indent -compact
123 struct ufs_args {
124 char *fspec; /* block special file to mount */
125 struct export_args export; /* network export information */
126 };
127 .Ed
128 .Pp
129 .Dv MOUNT_NFS
130 .Bd -literal -offset indent -compact
131 struct nfs_args {
132 int version; /* args structure version */
133 struct sockaddr *addr; /* file server address */
134 int addrlen; /* length of address */
135 int sotype; /* Socket type */
136 int proto; /* and Protocol */
137 u_char *fh; /* File handle to be mounted */
138 int fhsize; /* Size, in bytes, of fh */
139 int flags; /* flags */
140 int wsize; /* write size in bytes */
141 int rsize; /* read size in bytes */
142 int readdirsize; /* readdir size in bytes */
143 int timeo; /* initial timeout in .1 secs */
144 int retrans; /* times to retry send */
145 int maxgrouplist; /* Max. size of group list */
146 int readahead; /* # of blocks to readahead */
147 int leaseterm; /* Term (sec) of lease */
148 int deadthresh; /* Retrans threshold */
149 char *hostname; /* server's name */
150 };
151 .Ed
152 .Pp
153 .Dv MOUNT_MFS
154 .Bd -literal -offset indent -compact
155 struct mfs_args {
156 char *fspec; /* name to export for statfs */
157 struct export_args export; /* if we can export an MFS */
158 caddr_t base; /* base of filesystem in mem */
159 u_long size; /* size of filesystem */
160 };
161 .Ed
162 .Pp
163 The
164 .Fn umount
165 function call disassociates the filesystem from the specified
166 mount point
167 .Fa dir .
168 .Pp
169 The
170 .Fa flags
171 argument may specify
172 .Dv MNT_FORCE
173 to specify that the filesystem should be forcibly unmounted even if files are
174 still active.
175 Active special devices continue to work,
176 but any further accesses to any other active files result in errors
177 even if the filesystem is later remounted.
178 .Sh RETURN VALUES
179 The
180 .Fn mount
181 returns the value 0 if the mount was successful, otherwise -1 is returned
182 and the variable
183 .Va errno
184 is set to indicate the error.
185 .Pp
186 .Nm Umount
187 returns the value 0 if the umount succeeded; otherwise -1 is returned
188 and the variable
189 .Va errno
190 is set to indicate the error.
191 .Sh ERRORS
192 .Fn Mount
193 will fail when one of the following occurs:
194 .Bl -tag -width [ENAMETOOLONG]
195 .It Bq Er EPERM
196 The caller is not the super-user.
197 .It Bq Er ENAMETOOLONG
198 A component of a pathname exceeded
199 .Dv {NAME_MAX}
200 characters, or an entire path name exceeded
201 .Dv {PATH_MAX}
202 characters.
203 .It Bq Er ELOOP
204 Too many symbolic links were encountered in translating a pathname.
205 .It Bq Er ENOENT
206 A component of
207 .Fa dir
208 does not exist.
209 .It Bq Er ENOTDIR
210 A component of
211 .Ar name
212 is not a directory,
213 or a path prefix of
214 .Ar special
215 is not a directory.
216 .It Bq Er EINVAL
217 A pathname contains a character with the high-order bit set.
218 .It Bq Er EBUSY
219 Another process currently holds a reference to
220 .Fa dir .
221 .It Bq Er EFAULT
222 .Fa Dir
223 points outside the process's allocated address space.
224 .El
225 .Pp
226 The following errors can occur for a
227 .Em ufs
228 filesystem mount:
229 .Bl -tag -width [ENOTBLK]
230 .It Bq Er ENODEV
231 A component of ufs_args
232 .Ar fspec
233 does not exist.
234 .It Bq Er ENOTBLK
235 .Ar Fspec
236 is not a block device.
237 .It Bq Er ENXIO
238 The major device number of
239 .Ar fspec
240 is out of range (this indicates no device driver exists
241 for the associated hardware).
242 .It Bq Er EBUSY
243 .Ar Fspec
244 is already mounted.
245 .It Bq Er EMFILE
246 No space remains in the mount table.
247 .It Bq Er EINVAL
248 The super block for the filesystem had a bad magic
249 number or an out of range block size.
250 .It Bq Er ENOMEM
251 Not enough memory was available to read the cylinder
252 group information for the filesystem.
253 .It Bq Er EIO
254 An I/O error occurred while reading the super block or
255 cylinder group information.
256 .It Bq Er EFAULT
257 .Ar Fspec
258 points outside the process's allocated address space.
259 .El
260 .Pp
261 The following errors can occur for a
262 .Em nfs
263 filesystem mount:
264 .Bl -tag -width [ETIMEDOUT]
265 .It Bq Er ETIMEDOUT
266 .Em Nfs
267 timed out trying to contact the server.
268 .It Bq Er EFAULT
269 Some part of the information described by nfs_args
270 points outside the process's allocated address space.
271 .El
272 .Pp
273 The following errors can occur for a
274 .Em mfs
275 filesystem mount:
276 .Bl -tag -width [EMFILE]
277 .It Bq Er EMFILE
278 No space remains in the mount table.
279 .It Bq Er EINVAL
280 The super block for the filesystem had a bad magic
281 number or an out of range block size.
282 .It Bq Er ENOMEM
283 Not enough memory was available to read the cylinder
284 group information for the filesystem.
285 .It Bq Er EIO
286 A paging error occurred while reading the super block or
287 cylinder group information.
288 .It Bq Er EFAULT
289 .Em Name
290 points outside the process's allocated address space.
291 .El
292 .Pp
293 .Nm Umount
294 may fail with one of the following errors:
295 .Bl -tag -width [ENAMETOOLONG]
296 .It Bq Er EPERM
297 The caller is not the super-user.
298 .It Bq Er ENOTDIR
299 A component of the path is not a directory.
300 .It Bq Er EINVAL
301 The pathname contains a character with the high-order bit set.
302 .It Bq Er ENAMETOOLONG
303 A component of a pathname exceeded
304 .Dv {NAME_MAX}
305 characters, or an entire path name exceeded
306 .Dv {PATH_MAX}
307 characters.
308 .It Bq Er ELOOP
309 Too many symbolic links were encountered in translating the pathname.
310 .It Bq Er EINVAL
311 The requested directory is not in the mount table.
312 .It Bq Er EBUSY
313 A process is holding a reference to a file located
314 on the filesystem.
315 .It Bq Er EIO
316 An I/O error occurred while writing cached filesystem information.
317 .It Bq Er EFAULT
318 .Fa Dir
319 points outside the process's allocated address space.
320 .El
321 .Pp
322 A
323 .Em ufs
324 or
325 .Em mfs
326 mount can also fail if the maximum number of filesystems are currently
327 mounted.
328 .Sh SEE ALSO
329 .Xr mount 8 ,
330 .Xr umount 8 ,
331 .Xr mfs 8
332 .Sh BUGS
333 Some of the error codes need translation to more obvious messages.
334 .Sh HISTORY
335 .Fn Mount
336 and
337 .Fn umount
338 function calls appeared in
339 .At v6 .