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