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