1.\" $NetBSD: mount.2,v 1.15 1998/02/02 05:20:32 perry 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.3 (Berkeley) 5/24/95 35.\" 36.Dd May 24, 1995 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 "const char *type" "const char *dir" "int flags" "void *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_UNION 91Union with underlying filesystem instead of obscuring it. 92.It Dv MNT_SYNCHRONOUS 93All I/O to the file system should be done synchronously. 94.It Dv MNT_NOCOREDUMP 95Do not allow programs to dump core files on the file system. 96.El 97.Pp 98The flag 99.Dv MNT_UPDATE 100indicates that the mount command is being applied 101to an already mounted file system. 102This allows the mount flags to be changed without requiring 103that the file system be unmounted and remounted. 104Some file systems may not allow all flags to be changed. 105For example, 106most file systems will not allow a change from read-write to read-only. 107.Pp 108The 109.Fa type 110argument defines the type of the file system. 111The types of file systems known to the system are defined in 112.Aq Pa sys/mount.h . 113.\" XXX from lite-2: 114.\" The types of filesystems known to the system can be obtained with 115.\" .Xr sysctl 8 116.\" by using the command: 117.\" .Bd -literal -offset indent 118.\" sysctl vfs 119.\" .Ed 120.\" .Pp 121.Fa Data 122is a pointer to a structure that contains the type 123specific arguments to mount. 124The currently supported types of file systems and 125their type specific data are: 126.Pp 127.Dv MOUNT_FFS 128.Bd -literal -offset indent -compact 129struct ufs_args { 130 char *fspec; /* block special file to mount */ 131 struct export_args export; /* network export information */ 132}; 133.Ed 134.Pp 135.Dv MOUNT_NFS 136.Bd -literal -offset indent -compact 137struct nfs_args { 138 int version; /* args structure version */ 139 struct sockaddr *addr; /* file server address */ 140 int addrlen; /* length of address */ 141 int sotype; /* Socket type */ 142 int proto; /* and Protocol */ 143 u_char *fh; /* File handle to be mounted */ 144 int fhsize; /* Size, in bytes, of fh */ 145 int flags; /* flags */ 146 int wsize; /* write size in bytes */ 147 int rsize; /* read size in bytes */ 148 int readdirsize; /* readdir size in bytes */ 149 int timeo; /* initial timeout in .1 secs */ 150 int retrans; /* times to retry send */ 151 int maxgrouplist; /* Max. size of group list */ 152 int readahead; /* # of blocks to readahead */ 153 int leaseterm; /* Term (sec) of lease */ 154 int deadthresh; /* Retrans threshold */ 155 char *hostname; /* server's name */ 156}; 157.Ed 158.Pp 159.Dv MOUNT_MFS 160.Bd -literal -offset indent -compact 161struct mfs_args { 162 char *fspec; /* name to export for statfs */ 163 struct export_args export; /* if we can export an MFS */ 164 caddr_t base; /* base of file system in mem */ 165 u_long size; /* size of file system */ 166}; 167.Ed 168.\" XXX from lite-2: 169.\" The format for these argument structures is described in the 170.\" manual page for each filesystem. 171.\" By convention filesystem manual pages are named 172.\" by prefixing ``mount_'' to the name of the filesystem as returned by 173.\" .Xr sysctl 8 . 174.\" Thus the 175.\" .Nm NFS 176.\" filesystem is described by the 177.\" .Xr mount_nfs 8 178.\" manual page. 179.Pp 180The 181.Fn unmount 182function call disassociates the file system from the specified 183mount point 184.Fa dir . 185.Pp 186The 187.Fa flags 188argument may specify 189.Dv MNT_FORCE 190to specify that the file system should be forcibly unmounted even if files are 191still active. 192Active special devices continue to work, 193but any further accesses to any other active files result in errors 194even if the file system is later remounted. 195.Sh RETURN VALUES 196The 197.Fn mount 198returns the value 0 if the mount was successful, otherwise -1 is returned 199and the variable 200.Va errno 201is set to indicate the error. 202.Pp 203.Nm Unmount 204returns the value 0 if the unmount succeeded; otherwise -1 is returned 205and the variable 206.Va errno 207is set to indicate the error. 208.Sh ERRORS 209.Fn Mount 210will fail when one of the following occurs: 211.Bl -tag -width Er 212.It Bq Er EPERM 213The caller is not the super-user. 214.It Bq Er ENAMETOOLONG 215A component of a pathname exceeded 216.Dv {NAME_MAX} 217characters, or an entire path name exceeded 218.Dv {PATH_MAX} 219characters. 220.It Bq Er ELOOP 221Too many symbolic links were encountered in translating a pathname. 222.It Bq Er ENOENT 223A component of 224.Fa dir 225does not exist. 226.It Bq Er ENOTDIR 227A component of 228.Ar name 229is not a directory, 230or a path prefix of 231.Ar special 232is not a directory. 233.It Bq Er EBUSY 234Another process currently holds a reference to 235.Fa dir . 236.It Bq Er EFAULT 237.Fa Dir 238points outside the process's allocated address space. 239.El 240.Pp 241The following errors can occur for a 242.Em ufs 243file system mount: 244.Bl -tag -width Er 245.It Bq Er ENODEV 246A component of ufs_args 247.Ar fspec 248does not exist. 249.It Bq Er ENOTBLK 250.Ar Fspec 251is not a block device. 252.It Bq Er ENXIO 253The major device number of 254.Ar fspec 255is out of range (this indicates no device driver exists 256for the associated hardware). 257.It Bq Er EBUSY 258.Ar Fspec 259is already mounted. 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 I/O error occurred while reading the super block or 270cylinder group information. 271.It Bq Er EFAULT 272.Ar Fspec 273points outside the process's allocated address space. 274.El 275.Pp 276The following errors can occur for a 277.Em nfs 278file system mount: 279.Bl -tag -width Er 280.It Bq Er ETIMEDOUT 281.Em Nfs 282timed out trying to contact the server. 283.It Bq Er EFAULT 284Some part of the information described by nfs_args 285points outside the process's allocated address space. 286.El 287.Pp 288The following errors can occur for a 289.Em mfs 290file system mount: 291.Bl -tag -width Er 292.It Bq Er EMFILE 293No space remains in the mount table. 294.It Bq Er EINVAL 295The super block for the file system had a bad magic 296number or an out of range block size. 297.It Bq Er ENOMEM 298Not enough memory was available to read the cylinder 299group information for the file system. 300.It Bq Er EIO 301A paging error occurred while reading the super block or 302cylinder group information. 303.It Bq Er EFAULT 304.Em Name 305points outside the process's allocated address space. 306.El 307.Pp 308.Nm Unmount 309may fail with one of the following errors: 310.Bl -tag -width Er 311.It Bq Er EPERM 312The caller is not the super-user. 313.It Bq Er ENOTDIR 314A component of the path is not a directory. 315.It Bq Er ENAMETOOLONG 316A component of a pathname exceeded 317.Dv {NAME_MAX} 318characters, or an entire path name exceeded 319.Dv {PATH_MAX} 320characters. 321.It Bq Er ELOOP 322Too many symbolic links were encountered in translating the pathname. 323.It Bq Er EINVAL 324The requested directory is not in the mount table. 325.It Bq Er EBUSY 326A process is holding a reference to a file located 327on the file system. 328.It Bq Er EIO 329An I/O error occurred while writing cached file system information. 330.It Bq Er EFAULT 331.Fa Dir 332points outside the process's allocated address space. 333.El 334.Pp 335A 336.Em ufs 337or 338.Em mfs 339mount can also fail if the maximum number of file systems are currently 340mounted. 341.Sh SEE ALSO 342.Xr mount 8 , 343.Xr umount 8 , 344.Xr sysctl 8 345.Sh BUGS 346Some of the error codes need translation to more obvious messages. 347.Sh HISTORY 348.Fn Mount 349and 350.Fn umount 351(now unmount) function calls appeared in 352.At v6 . 353