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