1.\" $NetBSD: mount.2,v 1.8 1995/02/27 12:34:49 cgd Exp $ 2.\" 3.\" Copyright (c) 1980, 1989, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)mount.2 8.2 (Berkeley) 12/11/93 35.\" 36.Dd December 11, 1993 37.Dt MOUNT 2 38.Os BSD 4 39.Sh NAME 40.Nm mount , 41.Nm unmount 42.Nd mount or dismount a file system 43.Sh SYNOPSIS 44.Fd #include <sys/param.h> 45.Fd #include <sys/mount.h> 46.Ft int 47.Fn mount "int type" "const char *dir" "int flags" "caddr_t data" 48.Ft int 49.Fn unmount "const char *dir" "int flags" 50.Sh DESCRIPTION 51The 52.Fn mount 53function grafts 54a file system object onto the system file tree 55at the point 56.Ar dir . 57The argument 58.Ar data 59describes the file system object to be mounted. 60The argument 61.Ar type 62tells the kernel how to interpret 63.Ar data 64(See 65.Ar type 66below). 67The contents of the file system 68become available through the new mount point 69.Ar dir . 70Any files in 71.Ar dir 72at the time 73of a successful mount are swept under the carpet so to speak, and 74are unavailable until the file system is unmounted. 75.Pp 76The following 77.Ar flags 78may be specified to 79suppress default semantics which affect file system access. 80.Bl -tag -width MNT_SYNCHRONOUS 81.It Dv MNT_RDONLY 82The file system should be treated as read-only; 83Even the super-user may not write on it. 84.It Dv MNT_NOEXEC 85Do not allow files to be executed from the file system. 86.It Dv MNT_NOSUID 87Do not honor setuid or setgid bits on files when executing them. 88.It Dv MNT_NODEV 89Do not interpret special files on the file system. 90.It Dv MNT_SYNCHRONOUS 91All I/O to the file system should be done synchronously. 92.El 93.Pp 94The flag 95.Dv MNT_UPDATE 96indicates that the mount command is being applied 97to an already mounted file system. 98This allows the mount flags to be changed without requiring 99that the file system be unmounted and remounted. 100Some file systems may not allow all flags to be changed. 101For example, 102most file systems will not allow a change from read-write to read-only. 103.Pp 104The 105.Fa type 106argument defines the type of the file system. 107The types of file systems known to the system are defined in 108.Aq Pa sys/mount.h . 109.Fa Data 110is a pointer to a structure that contains the type 111specific arguments to mount. 112The currently supported types of file systems and 113their type specific data are: 114.Pp 115.Dv MOUNT_UFS 116.Bd -literal -offset indent -compact 117struct ufs_args { 118 char *fspec; /* Block special file to mount */ 119 int exflags; /* export related flags */ 120 uid_t exroot; /* mapping for root uid */ 121}; 122.Ed 123.Pp 124.Dv MOUNT_NFS 125.Bd -literal -offset indent -compact 126struct nfs_args { 127 struct sockaddr_in *addr; /* file server address */ 128 nfsv2fh_t *fh; /* File handle to be mounted */ 129 int flags; /* flags */ 130 int wsize; /* write size in bytes */ 131 int rsize; /* read size in bytes */ 132 int timeo; /* initial timeout 0.1 secs */ 133 int retrans; /* times to retry send */ 134 char *hostname; /* server's name */ 135}; 136.Ed 137.Pp 138.Dv MOUNT_MFS 139.Bd -literal -offset indent -compact 140struct mfs_args { 141 char *name; /* name of backing process */ 142 caddr_t base; /* base address of the file system */ 143 u_long size; /* size of the file system */ 144}; 145.Ed 146.Pp 147The 148.Fn umount 149function call disassociates the file system from the specified 150mount point 151.Fa dir . 152.Pp 153The 154.Fa flags 155argument may specify 156.Dv MNT_FORCE 157to specify that the file system should be forcibly unmounted even if files are 158still active. 159Active special devices continue to work, 160but any further accesses to any other active files result in errors 161even if the file system is later remounted. 162.Sh RETURN VALUES 163The 164.Fn mount 165returns the value 0 if the mount was successful, otherwise -1 is returned 166and the variable 167.Va errno 168is set to indicate the error. 169.Pp 170.Nm Umount 171returns the value 0 if the umount succeeded; otherwise -1 is returned 172and the variable 173.Va errno 174is set to indicate the error. 175.Sh ERRORS 176.Fn Mount 177will fail when one of the following occurs: 178.Bl -tag -width Er 179.It Bq Er EPERM 180The caller is not the super-user. 181.It Bq Er ENAMETOOLONG 182A component of a pathname exceeded 183.Dv {NAME_MAX} 184characters, or an entire path name exceeded 185.Dv {PATH_MAX} 186characters. 187.It Bq Er ELOOP 188Too many symbolic links were encountered in translating a pathname. 189.It Bq Er ENOENT 190A component of 191.Fa dir 192does not exist. 193.It Bq Er ENOTDIR 194A component of 195.Ar name 196is not a directory, 197or a path prefix of 198.Ar special 199is not a directory. 200.It Bq Er EBUSY 201Another process currently holds a reference to 202.Fa dir . 203.It Bq Er EFAULT 204.Fa Dir 205points outside the process's allocated address space. 206.El 207.Pp 208The following errors can occur for a 209.Em ufs 210file system mount: 211.Bl -tag -width Er 212.It Bq Er ENODEV 213A component of ufs_args 214.Ar fspec 215does not exist. 216.It Bq Er ENOTBLK 217.Ar Fspec 218is not a block device. 219.It Bq Er ENXIO 220The major device number of 221.Ar fspec 222is out of range (this indicates no device driver exists 223for the associated hardware). 224.It Bq Er EBUSY 225.Ar Fspec 226is already mounted. 227.It Bq Er EMFILE 228No space remains in the mount table. 229.It Bq Er EINVAL 230The super block for the file system had a bad magic 231number or an out of range block size. 232.It Bq Er ENOMEM 233Not enough memory was available to read the cylinder 234group information for the file system. 235.It Bq Er EIO 236An I/O error occurred while reading the super block or 237cylinder group information. 238.It Bq Er EFAULT 239.Ar Fspec 240points outside the process's allocated address space. 241.El 242.Pp 243The following errors can occur for a 244.Em nfs 245file system mount: 246.Bl -tag -width Er 247.It Bq Er ETIMEDOUT 248.Em Nfs 249timed out trying to contact the server. 250.It Bq Er EFAULT 251Some part of the information described by nfs_args 252points outside the process's allocated address space. 253.El 254.Pp 255The following errors can occur for a 256.Em mfs 257file system mount: 258.Bl -tag -width Er 259.It Bq Er EMFILE 260No space remains in the mount table. 261.It Bq Er EINVAL 262The super block for the file system had a bad magic 263number or an out of range block size. 264.It Bq Er ENOMEM 265Not enough memory was available to read the cylinder 266group information for the file system. 267.It Bq Er EIO 268A paging error occurred while reading the super block or 269cylinder group information. 270.It Bq Er EFAULT 271.Em Name 272points outside the process's allocated address space. 273.El 274.Pp 275.Nm Umount 276may fail with one of the following errors: 277.Bl -tag -width Er 278.It Bq Er EPERM 279The caller is not the super-user. 280.It Bq Er ENOTDIR 281A component of the path is not a directory. 282.It Bq Er ENAMETOOLONG 283A component of a pathname exceeded 284.Dv {NAME_MAX} 285characters, or an entire path name exceeded 286.Dv {PATH_MAX} 287characters. 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 file systems 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