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