Commit | Line | Data |
---|---|---|
156f4461 KM |
1 | .\" Copyright (c) 1980, 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
75f4d1ff | 3 | .\" |
af359dea C |
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. | |
156f4461 | 19 | .\" |
af359dea C |
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. | |
75f4d1ff | 31 | .\" |
af359dea C |
32 | .\" @(#)mount.2 6.12 (Berkeley) 3/15/91 |
33 | .\" | |
34 | .Dd March 15, 1991 | |
931b8415 CL |
35 | .Dt MOUNT 2 |
36 | .Os BSD 4 | |
37 | .Sh NAME | |
38 | .Nm mount , | |
39 | .Nm unmount | |
40 | .Nd mount or dismount a filesystem | |
41 | .Sh SYNOPSIS | |
42 | .Fd #include <sys/mount.h> | |
43 | .Ft int | |
44 | .Fn mount "int type" "const char *dir" "int flags" "caddr_t data" | |
45 | .Ft int | |
46 | .Fn unmount "const char *dir" "int flags" | |
47 | .Sh DESCRIPTION | |
75f4d1ff | 48 | The |
931b8415 CL |
49 | .Fn mount |
50 | function grafts | |
51 | a filesystem object onto the system file tree | |
52 | at the point | |
53 | .Ar dir . | |
54 | The argument | |
55 | .Ar data | |
56 | describes the filesystem object to be mounted. | |
57 | The argument | |
58 | .Ar type | |
59 | tells the kernel how to interpret | |
60 | .Ar data | |
61 | (See | |
62 | .Ar type | |
63 | below). | |
64 | The contents of the filesystem | |
65 | become available through the new mount point | |
66 | .Ar dir . | |
67 | Any files in | |
68 | .Ar dir | |
69 | at the time | |
70 | of a successful mount are swept under the carpet so to speak, and | |
71 | are unavailable until the filesystem is unmounted. | |
72 | .Pp | |
73 | The following | |
74 | .Ar flags | |
75 | may be specified to | |
76 | suppress default semantics which affect filesystem access. | |
77 | .Bl -tag -width M_SYNCHRONOUS | |
78 | .It Dv M_RDONLY | |
156f4461 | 79 | The file system should be treated as read-only; |
931b8415 CL |
80 | Even the super-user may not write on it. |
81 | .It Dv M_NOEXEC | |
156f4461 | 82 | Do not allow files to be executed from the file system. |
931b8415 | 83 | .It Dv M_NOSUID |
537ddbbc | 84 | Do not honor setuid or setgid bits on files when executing them. |
931b8415 | 85 | .It Dv M_NODEV |
156f4461 | 86 | Do not interpret special files on the file system. |
931b8415 | 87 | .It Dv M_SYNCHRONOUS |
156f4461 | 88 | All I/O to the file system should be done synchronously. |
931b8415 CL |
89 | .El |
90 | .Pp | |
91 | The flag | |
92 | .Dv M_UPDATE | |
93 | indicates that the mount command is being applied | |
f8865310 KM |
94 | to an already mounted file system. |
95 | This allows the mount flags to be changed without requiring | |
96 | that the file system be unmounted and remounted. | |
97 | Some file systems may not allow all flags to be changed. | |
98 | For example, | |
99 | most file systems will not allow a change from read-write to read-only. | |
931b8415 | 100 | .Pp |
156f4461 | 101 | The |
931b8415 | 102 | .Fa type |
156f4461 KM |
103 | argument defines the type of the file system. |
104 | The types of file systems known to the system are defined in | |
931b8415 CL |
105 | .Aq Pa sys/mount.h . |
106 | .Fa Data | |
156f4461 KM |
107 | is a pointer to a structure that contains the type |
108 | specific arguments to mount. | |
109 | The currently supported types of file systems and | |
110 | their type specific data are: | |
931b8415 CL |
111 | .Pp |
112 | .Dv MOUNT_UFS | |
619497d0 | 113 | .Bd -literal -offset indent -compact |
156f4461 | 114 | struct ufs_args { |
619497d0 CL |
115 | char *fspec; /* Block special file to mount */ |
116 | int exflags; /* export related flags */ | |
117 | uid_t exroot; /* mapping for root uid */ | |
156f4461 | 118 | }; |
931b8415 CL |
119 | .Ed |
120 | .Pp | |
121 | .Dv MOUNT_NFS | |
619497d0 | 122 | .Bd -literal -offset indent -compact |
156f4461 | 123 | struct nfs_args { |
619497d0 CL |
124 | struct sockaddr_in *addr; /* file server address */ |
125 | nfsv2fh_t *fh; /* File handle to be mounted */ | |
126 | int flags; /* flags */ | |
127 | int wsize; /* write size in bytes */ | |
128 | int rsize; /* read size in bytes */ | |
129 | int timeo; /* initial timeout 0.1 secs */ | |
130 | int retrans; /* times to retry send */ | |
131 | char *hostname; /* server's name */ | |
156f4461 | 132 | }; |
931b8415 CL |
133 | .Ed |
134 | .Pp | |
135 | .Dv MOUNT_MFS | |
619497d0 | 136 | .Bd -literal -offset indent -compact |
537ddbbc | 137 | struct mfs_args { |
619497d0 CL |
138 | char *name; /* name of backing process */ |
139 | caddr_t base; /* base address of the file system */ | |
140 | u_long size; /* size of the file system */ | |
537ddbbc | 141 | }; |
931b8415 CL |
142 | .Ed |
143 | .Pp | |
156f4461 | 144 | The |
931b8415 CL |
145 | .Fn umount |
146 | function call disassociates the filesystem from the specified | |
147 | mount point | |
148 | .Fa dir . | |
149 | .Pp | |
150 | The | |
151 | .Fa flags | |
152 | argument may have one of the following values: | |
153 | .Bl -tag -width M_SYNCHRONOUS | |
154 | .It Dv MNT_NOFORCE | |
156f4461 | 155 | The unmount should fail if any files are active on the file system. |
931b8415 | 156 | .It Dv MNT_FORCE |
156f4461 KM |
157 | The file system should be forcibly unmounted even if files are |
158 | still active. | |
f8a965b6 KM |
159 | Active special devices continue to work, |
160 | but any further accesses to any other active files result in errors | |
156f4461 | 161 | even if the file system is later remounted. |
931b8415 CL |
162 | .El |
163 | .Sh RETURN VALUES | |
164 | The | |
165 | .Fn mount | |
166 | returns the value 0 if the mount was successful, otherwise -1 is returned | |
167 | and the variable | |
168 | .Va errno | |
169 | is set to indicate the error. | |
170 | .Pp | |
171 | .Nm Umount | |
172 | returns the value 0 if the umount succeeded; otherwise -1 is returned | |
173 | and the variable | |
174 | .Va errno | |
175 | is set to indicate the error. | |
176 | .Sh ERRORS | |
177 | .Fn Mount | |
28e2febc | 178 | will fail when one of the following occurs: |
931b8415 CL |
179 | .Bl -tag -width [ENOTBLK] |
180 | .It Bq Er EPERM | |
156f4461 | 181 | The caller is not the super-user. |
931b8415 | 182 | .It Bq Er ENAMETOOLONG |
156f4461 KM |
183 | A component of a pathname exceeded 255 characters, |
184 | or the entire length of a path name exceeded 1023 characters. | |
931b8415 | 185 | .It Bq Er ELOOP |
156f4461 | 186 | Too many symbolic links were encountered in translating a pathname. |
931b8415 CL |
187 | .It Bq Er ENOENT |
188 | A component of | |
189 | .Fa dir | |
190 | does not exist. | |
191 | .It Bq Er ENOTDIR | |
192 | A component of | |
193 | .Ar name | |
194 | is not a directory, | |
195 | or a path prefix of | |
196 | .Ar special | |
197 | is not a directory. | |
198 | .It Bq Er EINVAL | |
156f4461 | 199 | A pathname contains a character with the high-order bit set. |
931b8415 | 200 | .It Bq Er EBUSY |
156f4461 | 201 | Another process currently holds a reference to |
931b8415 CL |
202 | .Fa dir . |
203 | .It Bq Er EFAULT | |
204 | .Fa Dir | |
205 | points outside the process's allocated address space. | |
206 | .El | |
207 | .Pp | |
156f4461 | 208 | The following errors can occur for a |
931b8415 | 209 | .Em ufs |
156f4461 | 210 | file system mount: |
931b8415 CL |
211 | .Bl -tag -width [ENOTBLK] |
212 | .It Bq Er ENODEV | |
213 | A component of ufs_args | |
214 | .Ar fspec | |
215 | does not exist. | |
216 | .It Bq Er ENOTBLK | |
217 | .Ar Fspec | |
28e2febc | 218 | is not a block device. |
931b8415 | 219 | .It Bq Er ENXIO |
28e2febc | 220 | The major device number of |
931b8415 | 221 | .Ar fspec |
28e2febc KM |
222 | is out of range (this indicates no device driver exists |
223 | for the associated hardware). | |
931b8415 CL |
224 | .It Bq Er EBUSY |
225 | .Ar Fspec | |
226 | is already mounted. | |
227 | .It Bq Er EMFILE | |
156f4461 | 228 | No space remains in the mount table. |
931b8415 | 229 | .It Bq Er EINVAL |
28e2febc KM |
230 | The super block for the file system had a bad magic |
231 | number or an out of range block size. | |
931b8415 | 232 | .It Bq Er ENOMEM |
28e2febc KM |
233 | Not enough memory was available to read the cylinder |
234 | group information for the file system. | |
931b8415 | 235 | .It Bq Er EIO |
fd690c8b | 236 | An I/O error occurred while reading the super block or |
28e2febc | 237 | cylinder group information. |
931b8415 CL |
238 | .It Bq Er EFAULT |
239 | .Ar Fspec | |
240 | points outside the process's allocated address space. | |
241 | .El | |
242 | .Pp | |
156f4461 | 243 | The following errors can occur for a |
931b8415 | 244 | .Em nfs |
156f4461 | 245 | file system mount: |
931b8415 CL |
246 | .Bl -tag -width [ENOTBLK] |
247 | .It Bq Er ETIMEDOUT | |
248 | .Em Nfs | |
156f4461 | 249 | timed out trying to contact the server. |
931b8415 | 250 | .It Bq Er EFAULT |
156f4461 KM |
251 | Some part of the information described by nfs_args |
252 | points outside the process's allocated address space. | |
931b8415 CL |
253 | .El |
254 | .Pp | |
537ddbbc | 255 | The following errors can occur for a |
931b8415 | 256 | .Em mfs |
537ddbbc | 257 | file system mount: |
931b8415 CL |
258 | .Bl -tag -width [ENOTBLK] |
259 | .It Bq Er EMFILE | |
537ddbbc | 260 | No space remains in the mount table. |
931b8415 | 261 | .It Bq Er EINVAL |
537ddbbc KM |
262 | The super block for the file system had a bad magic |
263 | number or an out of range block size. | |
931b8415 | 264 | .It Bq Er ENOMEM |
537ddbbc KM |
265 | Not enough memory was available to read the cylinder |
266 | group information for the file system. | |
931b8415 | 267 | .It Bq Er EIO |
537ddbbc KM |
268 | An paging error occurred while reading the super block or |
269 | cylinder group information. | |
931b8415 CL |
270 | .It Bq Er EFAULT |
271 | .Em Name | |
272 | points outside the process's allocated address space. | |
273 | .El | |
274 | .Pp | |
619497d0 | 275 | .Nm Umount |
28e2febc | 276 | may fail with one of the following errors: |
931b8415 CL |
277 | .Bl -tag -width [ENOTBLK] |
278 | .It Bq Er EPERM | |
156f4461 | 279 | The caller is not the super-user. |
931b8415 | 280 | .It Bq Er ENOTDIR |
156f4461 | 281 | A component of the path is not a directory. |
931b8415 | 282 | .It Bq Er EINVAL |
b5984ffe | 283 | The pathname contains a character with the high-order bit set. |
931b8415 | 284 | .It Bq Er ENAMETOOLONG |
b5984ffe KM |
285 | A component of a pathname exceeded 255 characters, |
286 | or an entire path name exceeded 1023 characters. | |
931b8415 | 287 | .It Bq Er ELOOP |
b5984ffe | 288 | Too many symbolic links were encountered in translating the pathname. |
931b8415 | 289 | .It Bq Er EINVAL |
156f4461 | 290 | The requested directory is not in the mount table. |
931b8415 | 291 | .It Bq Er EBUSY |
28e2febc KM |
292 | A process is holding a reference to a file located |
293 | on the file system. | |
931b8415 | 294 | .It Bq Er EIO |
156f4461 | 295 | An I/O error occurred while writing cached file system information. |
931b8415 CL |
296 | .It Bq Er EFAULT |
297 | .Fa Dir | |
298 | points outside the process's allocated address space. | |
299 | .El | |
300 | .Pp | |
301 | A | |
302 | .Em ufs | |
303 | or | |
304 | .Em mfs | |
305 | mount can also fail if the maximum number of filesystems are currently | |
306 | mounted. | |
307 | .Sh SEE ALSO | |
308 | .Xr mount 8 , | |
309 | .Xr umount 8 , | |
310 | .Xr mfs 8 | |
311 | .Sh BUGS | |
b5984ffe | 312 | Some of the error codes need translation to more obvious messages. |
931b8415 CL |
313 | .Sh HISTORY |
314 | .Fn Mount | |
315 | and | |
316 | .Fn umount | |
317 | function calls appeared in Version 6 AT&T UNIX. |