1.\" $OpenBSD: mount.2,v 1.21 2001/04/22 17:23:56 krw Exp $ 2.\" $NetBSD: mount.2,v 1.12 1996/02/29 23:47:48 jtc Exp $ 3.\" 4.\" Copyright (c) 1980, 1989, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)mount.2 8.2 (Berkeley) 12/11/93 36.\" 37.Dd December 11, 1993 38.Dt MOUNT 2 39.Os 40.Sh NAME 41.Nm mount , 42.Nm unmount 43.Nd mount or dismount a filesystem 44.Sh SYNOPSIS 45.Fd #include <sys/param.h> 46.Fd #include <sys/mount.h> 47.Ft int 48.Fn mount "const char *type" "const char *dir" "int flags" "void *data" 49.Ft int 50.Fn unmount "const char *dir" "int flags" 51.Sh DESCRIPTION 52The 53.Fn mount 54function grafts 55a filesystem object onto the system file tree 56at the point 57.Fa dir . 58The argument 59.Fa data 60describes the filesystem object to be mounted. 61The argument 62.Fa type 63tells the kernel how to interpret 64.Fa data 65(see 66.Fa type 67below). 68The contents of the filesystem 69become available through the new mount point 70.Fa dir . 71Any files in 72.Fa dir 73at the time 74of a successful mount are swept under the carpet, so to speak, and 75are unavailable until the filesystem is unmounted. 76.Pp 77The following 78.Fa flags 79may be specified to 80suppress default semantics which affect filesystem access. 81.Bl -tag -width MNT_SYNCHRONOUS 82.It Dv MNT_RDONLY 83The filesystem should be treated as read-only: 84even the superuser may not write to it. 85.It Dv MNT_NOATIME 86Do not update the access time on files in the filesystem unless 87the modification or status change times are also being updated. 88.It Dv MNT_NOEXEC 89Do not allow files to be executed from the filesystem. 90.It Dv MNT_NOSUID 91Do not honor setuid or setgid bits on files when executing them. 92.It Dv MNT_NODEV 93Do not interpret special files on the filesystem. 94.It Dv MNT_UNION 95Mount in such a way that the contents of the underlying filesystem are 96not (totally) obscured (see 97.Xr mount_union 8 ) . 98.It Dv MNT_SYNCHRONOUS 99All I/O to the filesystem should be done synchronously. 100.It Dv MNT_ASYNC 101All I/O to the filesystem should be done asynchronously. 102.It Dv MNT_SOFTDEP 103Use soft dependencies. 104Applies to FFS filesystems only (see 'softdep' in 105.Xr mount 8 ) . 106.El 107.Pp 108The flag 109.Dv MNT_UPDATE 110indicates that the mount command is being applied 111to an already mounted filesystem. 112This allows the mount flags to be changed without requiring 113that the filesystem be unmounted and remounted. 114Some filesystems may not allow all flags to be changed. 115For example, 116most filesystems will not allow a change from read-write to read-only. 117.Pp 118The 119.Fa type 120argument defines the type of the filesystem. 121The types of filesystems known to the system are defined in 122.Aq Pa sys/mount.h . 123.Fa data 124is a pointer to a structure that contains the type 125specific arguments to mount. 126The currently supported types of filesystems and 127their type specific data are: 128.Pp 129.Dv MOUNT_ADOSFS 130.Bd -literal -offset indent -compact 131struct adosfs_args { 132 char *fspec; /* blocks special holding fs to mount */ 133 struct export_args export; 134 /* network export information */ 135 uid_t uid; /* uid that owns adosfs files */ 136 gid_t gid; /* gid that owns adosfs files */ 137 mode_t mask; /* mask to be applied for adosfs perms */ 138}; 139.Ed 140.Pp 141.Dv MOUNT_CD9660 142.Bd -literal -offset indent -compact 143struct iso_args { 144 char *fspec; /* block special device to mount */ 145 struct export_args export; 146 /* network export info */ 147 int flags; /* mounting flags, see below */ 148}; 149#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/ 150#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */ 151#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */ 152#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/ 153.Ed 154.Pp 155.Dv MOUNT_FFS 156.Bd -literal -offset indent -compact 157struct ufs_args { 158 char *fspec; /* block special file to mount */ 159 struct export_args export; /* network export information */ 160}; 161.Ed 162.Pp 163.Dv MOUNT_MFS 164.Bd -literal -offset indent -compact 165struct mfs_args { 166 char *fspec; /* name to export for statfs */ 167 struct export_args export; /* if we can export an MFS */ 168 caddr_t base; /* base of filesystem in mem */ 169 u_long size; /* size of filesystem */ 170}; 171.Ed 172.Pp 173.Dv MOUNT_MSDOS 174.Bd -literal -offset indent -compact 175struct msdosfs_args { 176 char *fspec; /* blocks special holding fs to mount */ 177 struct export_args export; 178 /* network export information */ 179 uid_t uid; /* uid that owns msdosfs files */ 180 gid_t gid; /* gid that owns msdosfs files */ 181 mode_t mask; /* mask to be applied for msdosfs perms */ 182 int flags; /* see below */ 183}; 184 185/* 186 * Msdosfs mount options: 187 */ 188#define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */ 189#define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */ 190#define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */ 191#define MSDOSFSMNT_GEMDOSFS 8 /* This is a gemdos-flavour */ 192.Ed 193.Dv MOUNT_NFS 194.Bd -literal -offset indent -compact 195struct nfs_args { 196 int version; /* args structure version */ 197 struct sockaddr *addr; /* file server address */ 198 int addrlen; /* length of address */ 199 int sotype; /* Socket type */ 200 int proto; /* and Protocol */ 201 u_char *fh; /* File handle to be mounted */ 202 int fhsize; /* Size, in bytes, of fh */ 203 int flags; /* flags */ 204 int wsize; /* write size in bytes */ 205 int rsize; /* read size in bytes */ 206 int readdirsize; /* readdir size in bytes */ 207 int timeo; /* initial timeout in .1 secs */ 208 int retrans; /* times to retry send */ 209 int maxgrouplist; /* Max. size of group list */ 210 int readahead; /* # of blocks to readahead */ 211 int leaseterm; /* Term (sec) of lease */ 212 int deadthresh; /* Retrans threshold */ 213 char *hostname; /* server's name */ 214 int acregmin; /* Attr cache file recently modified */ 215 int acregmax; /* ac file not recently modified */ 216 int acdirmin; /* ac for dir recently modified */ 217 int acdirmax; /* ac for dir not recently modified */ 218}; 219.Ed 220.Pp 221The 222.Fn unmount 223function call disassociates the filesystem from the specified 224mount point 225.Fa dir . 226.Pp 227The 228.Fa flags 229argument may specify 230.Dv MNT_FORCE 231to specify that the filesystem should be forcibly unmounted even if files are 232still active. 233Active special devices continue to work, 234but any further accesses to any other active files result in errors 235even if the filesystem is later remounted. 236.Sh RETURN VALUES 237.Fn mount 238returns the value 0 if the mount was successful; otherwise, \-1 is returned 239and the variable 240.Va errno 241is set to indicate the error. 242.Pp 243.Fn unmount 244returns the value 0 if the unmount was successful; otherwise, \-1 is returned 245and the variable 246.Va errno 247is set to indicate the error. 248.Sh ERRORS 249.Fn mount 250will fail when one of the following occurs: 251.Bl -tag -width [ENAMETOOLONG] 252.It Bq Er EPERM 253The caller is not the superuser. 254.It Bq Er ENAMETOOLONG 255A component of a pathname exceeded 256.Dv {NAME_MAX} 257characters, or an entire path name exceeded 258.Dv {PATH_MAX} 259characters. 260.It Bq Er ELOOP 261Too many symbolic links were encountered in translating a pathname. 262.It Bq Er ENOENT 263A component of 264.Fa dir 265does not exist. 266.It Bq Er ENOTDIR 267A component of 268.Ar name 269is not a directory, 270or a path prefix of 271.Ar special 272is not a directory. 273.It Bq Er EINVAL 274A pathname contains a character with the high-order bit set. 275.It Bq Er EBUSY 276Another process currently holds a reference to 277.Fa dir . 278.It Bq Er EFAULT 279.Fa dir 280points outside the process's allocated address space. 281.It Bq Er EOPNOTSUPP 282.Fa type 283is not supported by the kernel. 284.El 285.Pp 286The following errors can occur for a 287.Dq ufs 288filesystem mount: 289.Bl -tag -width [ENOTBLK] 290.It Bq Er ENODEV 291A component of ufs_args 292.Fa fspec 293does not exist. 294.It Bq Er ENOTBLK 295.Fa fspec 296is not a block device. 297.It Bq Er ENXIO 298The major device number of 299.Fa fspec 300is out of range (this indicates no device driver exists 301for the associated hardware). 302.It Bq Er EBUSY 303.Fa fspec 304is already mounted. 305.It Bq Er EMFILE 306No space remains in the mount table. 307.It Bq Er EINVAL 308The super block for the filesystem had a bad magic number, an out of range 309block size, or an invalid combination of flags. 310.It Bq Er ENOMEM 311Not enough memory was available to read the cylinder 312group information for the filesystem. 313.It Bq Er EIO 314An I/O error occurred while reading the super block or 315cylinder group information. 316.It Bq Er EFAULT 317.Fa fspec 318points outside the process's allocated address space. 319.El 320.Pp 321The following errors can occur for a 322.Em nfs 323filesystem mount: 324.Bl -tag -width [ETIMEDOUT] 325.It Bq Er ETIMEDOUT 326.Em Nfs 327timed out trying to contact the server. 328.It Bq Er EFAULT 329Some part of the information described by nfs_args 330points outside the process's allocated address space. 331.El 332.Pp 333The following errors can occur for a 334.Em mfs 335filesystem mount: 336.Bl -tag -width [EMFILE] 337.It Bq Er EMFILE 338No space remains in the mount table. 339.It Bq Er EINVAL 340The super block for the filesystem had a bad magic 341number or an out of range block size. 342.It Bq Er ENOMEM 343Not enough memory was available to read the cylinder 344group information for the filesystem. 345.It Bq Er EIO 346A paging error occurred while reading the super block or 347cylinder group information. 348.It Bq Er EFAULT 349.Em Name 350points outside the process's allocated address space. 351.El 352.Pp 353.Fn unmount 354may fail with one of the following errors: 355.Bl -tag -width [ENAMETOOLONG] 356.It Bq Er EPERM 357The caller is not the superuser. 358.It Bq Er ENOTDIR 359A component of the path is not a directory. 360.It Bq Er EINVAL 361The pathname contains a character with the high-order bit set. 362.It Bq Er ENAMETOOLONG 363A component of a pathname exceeded 364.Dv {NAME_MAX} 365characters, or an entire path name exceeded 366.Dv {PATH_MAX} 367characters. 368.It Bq Er ELOOP 369Too many symbolic links were encountered in translating the pathname. 370.It Bq Er EINVAL 371The requested directory is not in the mount table. 372.It Bq Er EBUSY 373A process is holding a reference to a file located 374on the filesystem. 375.It Bq Er EIO 376An I/O error occurred while writing cached filesystem information. 377.It Bq Er EFAULT 378.Fa dir 379points outside the process's allocated address space. 380.El 381.Pp 382A 383.Dq ufs 384or 385.Dq mfs 386mount can also fail if the maximum number of filesystems are currently 387mounted. 388.Sh SEE ALSO 389.Xr statfs 2 , 390.Xr mfs 8 , 391.Xr mount 8 , 392.Xr umount 8 393.Sh BUGS 394Some of the error codes need translation to more obvious messages. 395.Sh HISTORY 396.Fn mount 397and 398.Fn unmount 399function calls appeared in 400.At v6 . 401