1.\" $NetBSD: mount.2,v 1.13 1996/10/23 22:54:26 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 "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.Fa Data 114is a pointer to a structure that contains the type 115specific arguments to mount. 116The currently supported types of file systems and 117their type specific data are: 118.Pp 119.Dv MOUNT_FFS 120.Bd -literal -offset indent -compact 121struct ufs_args { 122 char *fspec; /* block special file to mount */ 123 struct export_args export; /* network export information */ 124}; 125.Ed 126.Pp 127.Dv MOUNT_NFS 128.Bd -literal -offset indent -compact 129struct nfs_args { 130 int version; /* args structure version */ 131 struct sockaddr *addr; /* file server address */ 132 int addrlen; /* length of address */ 133 int sotype; /* Socket type */ 134 int proto; /* and Protocol */ 135 u_char *fh; /* File handle to be mounted */ 136 int fhsize; /* Size, in bytes, of fh */ 137 int flags; /* flags */ 138 int wsize; /* write size in bytes */ 139 int rsize; /* read size in bytes */ 140 int readdirsize; /* readdir size in bytes */ 141 int timeo; /* initial timeout in .1 secs */ 142 int retrans; /* times to retry send */ 143 int maxgrouplist; /* Max. size of group list */ 144 int readahead; /* # of blocks to readahead */ 145 int leaseterm; /* Term (sec) of lease */ 146 int deadthresh; /* Retrans threshold */ 147 char *hostname; /* server's name */ 148}; 149.Ed 150.Pp 151.Dv MOUNT_MFS 152.Bd -literal -offset indent -compact 153struct mfs_args { 154 char *fspec; /* name to export for statfs */ 155 struct export_args export; /* if we can export an MFS */ 156 caddr_t base; /* base of file system in mem */ 157 u_long size; /* size of file system */ 158}; 159.Ed 160.Pp 161The 162.Fn umount 163function call disassociates the file system from the specified 164mount point 165.Fa dir . 166.Pp 167The 168.Fa flags 169argument may specify 170.Dv MNT_FORCE 171to specify that the file system should be forcibly unmounted even if files are 172still active. 173Active special devices continue to work, 174but any further accesses to any other active files result in errors 175even if the file system is later remounted. 176.Sh RETURN VALUES 177The 178.Fn mount 179returns the value 0 if the mount was successful, otherwise -1 is returned 180and the variable 181.Va errno 182is set to indicate the error. 183.Pp 184.Nm Umount 185returns the value 0 if the umount succeeded; otherwise -1 is returned 186and the variable 187.Va errno 188is set to indicate the error. 189.Sh ERRORS 190.Fn Mount 191will fail when one of the following occurs: 192.Bl -tag -width Er 193.It Bq Er EPERM 194The caller is not the super-user. 195.It Bq Er ENAMETOOLONG 196A component of a pathname exceeded 197.Dv {NAME_MAX} 198characters, or an entire path name exceeded 199.Dv {PATH_MAX} 200characters. 201.It Bq Er ELOOP 202Too many symbolic links were encountered in translating a pathname. 203.It Bq Er ENOENT 204A component of 205.Fa dir 206does not exist. 207.It Bq Er ENOTDIR 208A component of 209.Ar name 210is not a directory, 211or a path prefix of 212.Ar special 213is not a directory. 214.It Bq Er EBUSY 215Another process currently holds a reference to 216.Fa dir . 217.It Bq Er EFAULT 218.Fa Dir 219points outside the process's allocated address space. 220.El 221.Pp 222The following errors can occur for a 223.Em ufs 224file system mount: 225.Bl -tag -width Er 226.It Bq Er ENODEV 227A component of ufs_args 228.Ar fspec 229does not exist. 230.It Bq Er ENOTBLK 231.Ar Fspec 232is not a block device. 233.It Bq Er ENXIO 234The major device number of 235.Ar fspec 236is out of range (this indicates no device driver exists 237for the associated hardware). 238.It Bq Er EBUSY 239.Ar Fspec 240is already mounted. 241.It Bq Er EMFILE 242No space remains in the mount table. 243.It Bq Er EINVAL 244The super block for the file system had a bad magic 245number or an out of range block size. 246.It Bq Er ENOMEM 247Not enough memory was available to read the cylinder 248group information for the file system. 249.It Bq Er EIO 250An I/O error occurred while reading the super block or 251cylinder group information. 252.It Bq Er EFAULT 253.Ar Fspec 254points outside the process's allocated address space. 255.El 256.Pp 257The following errors can occur for a 258.Em nfs 259file system mount: 260.Bl -tag -width Er 261.It Bq Er ETIMEDOUT 262.Em Nfs 263timed out trying to contact the server. 264.It Bq Er EFAULT 265Some part of the information described by nfs_args 266points outside the process's allocated address space. 267.El 268.Pp 269The following errors can occur for a 270.Em mfs 271file system mount: 272.Bl -tag -width Er 273.It Bq Er EMFILE 274No space remains in the mount table. 275.It Bq Er EINVAL 276The super block for the file system had a bad magic 277number or an out of range block size. 278.It Bq Er ENOMEM 279Not enough memory was available to read the cylinder 280group information for the file system. 281.It Bq Er EIO 282A paging error occurred while reading the super block or 283cylinder group information. 284.It Bq Er EFAULT 285.Em Name 286points outside the process's allocated address space. 287.El 288.Pp 289.Nm Umount 290may fail with one of the following errors: 291.Bl -tag -width Er 292.It Bq Er EPERM 293The caller is not the super-user. 294.It Bq Er ENOTDIR 295A component of the path is not a directory. 296.It Bq Er ENAMETOOLONG 297A component of a pathname exceeded 298.Dv {NAME_MAX} 299characters, or an entire path name exceeded 300.Dv {PATH_MAX} 301characters. 302.It Bq Er ELOOP 303Too many symbolic links were encountered in translating the pathname. 304.It Bq Er EINVAL 305The requested directory is not in the mount table. 306.It Bq Er EBUSY 307A process is holding a reference to a file located 308on the file system. 309.It Bq Er EIO 310An I/O error occurred while writing cached file system information. 311.It Bq Er EFAULT 312.Fa Dir 313points outside the process's allocated address space. 314.El 315.Pp 316A 317.Em ufs 318or 319.Em mfs 320mount can also fail if the maximum number of file systems are currently 321mounted. 322.Sh SEE ALSO 323.Xr mount 8 , 324.Xr umount 8 , 325.Xr mfs 8 326.Sh BUGS 327Some of the error codes need translation to more obvious messages. 328.Sh HISTORY 329.Fn Mount 330and 331.Fn umount 332function calls appeared in 333.At v6 . 334