| 1 | .\" Copyright (c) 1980, 1989 The Regents of the University of California. |
| 2 | .\" 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 6.12 (Berkeley) 3/15/91 |
| 33 | .\" |
| 34 | .Dd March 15, 1991 |
| 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 |
| 48 | The |
| 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 |
| 79 | The file system should be treated as read-only; |
| 80 | Even the super-user may not write on it. |
| 81 | .It Dv M_NOEXEC |
| 82 | Do not allow files to be executed from the file system. |
| 83 | .It Dv M_NOSUID |
| 84 | Do not honor setuid or setgid bits on files when executing them. |
| 85 | .It Dv M_NODEV |
| 86 | Do not interpret special files on the file system. |
| 87 | .It Dv M_SYNCHRONOUS |
| 88 | All I/O to the file system should be done synchronously. |
| 89 | .El |
| 90 | .Pp |
| 91 | The flag |
| 92 | .Dv M_UPDATE |
| 93 | indicates that the mount command is being applied |
| 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. |
| 100 | .Pp |
| 101 | The |
| 102 | .Fa type |
| 103 | argument defines the type of the file system. |
| 104 | The types of file systems known to the system are defined in |
| 105 | .Aq Pa sys/mount.h . |
| 106 | .Fa Data |
| 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: |
| 111 | .Pp |
| 112 | .Dv MOUNT_UFS |
| 113 | .Bd -literal -offset indent -compact |
| 114 | struct ufs_args { |
| 115 | char *fspec; /* Block special file to mount */ |
| 116 | int exflags; /* export related flags */ |
| 117 | uid_t exroot; /* mapping for root uid */ |
| 118 | }; |
| 119 | .Ed |
| 120 | .Pp |
| 121 | .Dv MOUNT_NFS |
| 122 | .Bd -literal -offset indent -compact |
| 123 | struct nfs_args { |
| 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 */ |
| 132 | }; |
| 133 | .Ed |
| 134 | .Pp |
| 135 | .Dv MOUNT_MFS |
| 136 | .Bd -literal -offset indent -compact |
| 137 | struct mfs_args { |
| 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 */ |
| 141 | }; |
| 142 | .Ed |
| 143 | .Pp |
| 144 | The |
| 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 |
| 155 | The unmount should fail if any files are active on the file system. |
| 156 | .It Dv MNT_FORCE |
| 157 | The file system should be forcibly unmounted even if files are |
| 158 | still active. |
| 159 | Active special devices continue to work, |
| 160 | but any further accesses to any other active files result in errors |
| 161 | even if the file system is later remounted. |
| 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 |
| 178 | will fail when one of the following occurs: |
| 179 | .Bl -tag -width [ENOTBLK] |
| 180 | .It Bq Er EPERM |
| 181 | The caller is not the super-user. |
| 182 | .It Bq Er ENAMETOOLONG |
| 183 | A component of a pathname exceeded 255 characters, |
| 184 | or the entire length of a path name exceeded 1023 characters. |
| 185 | .It Bq Er ELOOP |
| 186 | Too many symbolic links were encountered in translating a pathname. |
| 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 |
| 199 | A pathname contains a character with the high-order bit set. |
| 200 | .It Bq Er EBUSY |
| 201 | Another process currently holds a reference to |
| 202 | .Fa dir . |
| 203 | .It Bq Er EFAULT |
| 204 | .Fa Dir |
| 205 | points outside the process's allocated address space. |
| 206 | .El |
| 207 | .Pp |
| 208 | The following errors can occur for a |
| 209 | .Em ufs |
| 210 | file system mount: |
| 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 |
| 218 | is not a block device. |
| 219 | .It Bq Er ENXIO |
| 220 | The major device number of |
| 221 | .Ar fspec |
| 222 | is out of range (this indicates no device driver exists |
| 223 | for the associated hardware). |
| 224 | .It Bq Er EBUSY |
| 225 | .Ar Fspec |
| 226 | is already mounted. |
| 227 | .It Bq Er EMFILE |
| 228 | No space remains in the mount table. |
| 229 | .It Bq Er EINVAL |
| 230 | The super block for the file system had a bad magic |
| 231 | number or an out of range block size. |
| 232 | .It Bq Er ENOMEM |
| 233 | Not enough memory was available to read the cylinder |
| 234 | group information for the file system. |
| 235 | .It Bq Er EIO |
| 236 | An I/O error occurred while reading the super block or |
| 237 | cylinder group information. |
| 238 | .It Bq Er EFAULT |
| 239 | .Ar Fspec |
| 240 | points outside the process's allocated address space. |
| 241 | .El |
| 242 | .Pp |
| 243 | The following errors can occur for a |
| 244 | .Em nfs |
| 245 | file system mount: |
| 246 | .Bl -tag -width [ENOTBLK] |
| 247 | .It Bq Er ETIMEDOUT |
| 248 | .Em Nfs |
| 249 | timed out trying to contact the server. |
| 250 | .It Bq Er EFAULT |
| 251 | Some part of the information described by nfs_args |
| 252 | points outside the process's allocated address space. |
| 253 | .El |
| 254 | .Pp |
| 255 | The following errors can occur for a |
| 256 | .Em mfs |
| 257 | file system mount: |
| 258 | .Bl -tag -width [ENOTBLK] |
| 259 | .It Bq Er EMFILE |
| 260 | No space remains in the mount table. |
| 261 | .It Bq Er EINVAL |
| 262 | The super block for the file system had a bad magic |
| 263 | number or an out of range block size. |
| 264 | .It Bq Er ENOMEM |
| 265 | Not enough memory was available to read the cylinder |
| 266 | group information for the file system. |
| 267 | .It Bq Er EIO |
| 268 | An paging error occurred while reading the super block or |
| 269 | cylinder group information. |
| 270 | .It Bq Er EFAULT |
| 271 | .Em Name |
| 272 | points outside the process's allocated address space. |
| 273 | .El |
| 274 | .Pp |
| 275 | .Nm Umount |
| 276 | may fail with one of the following errors: |
| 277 | .Bl -tag -width [ENOTBLK] |
| 278 | .It Bq Er EPERM |
| 279 | The caller is not the super-user. |
| 280 | .It Bq Er ENOTDIR |
| 281 | A component of the path is not a directory. |
| 282 | .It Bq Er EINVAL |
| 283 | The pathname contains a character with the high-order bit set. |
| 284 | .It Bq Er ENAMETOOLONG |
| 285 | A component of a pathname exceeded 255 characters, |
| 286 | or an entire path name exceeded 1023 characters. |
| 287 | .It Bq Er ELOOP |
| 288 | Too many symbolic links were encountered in translating the pathname. |
| 289 | .It Bq Er EINVAL |
| 290 | The requested directory is not in the mount table. |
| 291 | .It Bq Er EBUSY |
| 292 | A process is holding a reference to a file located |
| 293 | on the file system. |
| 294 | .It Bq Er EIO |
| 295 | An I/O error occurred while writing cached file system information. |
| 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 |
| 312 | Some of the error codes need translation to more obvious messages. |
| 313 | .Sh HISTORY |
| 314 | .Fn Mount |
| 315 | and |
| 316 | .Fn umount |
| 317 | function calls appeared in Version 6 AT&T UNIX. |