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