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