1.\" $OpenBSD: mount.2,v 1.40 2011/11/17 14:26:14 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: November 17 2011 $ 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.Aq Pa 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.Fn mount 247returns the value 0 if the mount was successful; otherwise, \-1 is returned 248and the variable 249.Va errno 250is set to indicate the error. 251.Pp 252.Fn unmount 253returns the value 0 if the unmount was successful; otherwise, \-1 is returned 254and the variable 255.Va errno 256is set to indicate the error. 257.Sh ERRORS 258.Fn mount 259will fail when one of the following occurs: 260.Bl -tag -width [ENAMETOOLONG] 261.It Bq Er EPERM 262The caller is not the superuser. 263.It Bq Er ENAMETOOLONG 264The path name exceeded 265.Dv {MNAMELEN} 266characters. 267.It Bq Er ELOOP 268Too many symbolic links were encountered in translating a pathname. 269.It Bq Er ENOENT 270A component of 271.Fa dir 272does not exist. 273.It Bq Er ENOTDIR 274A component of 275.Ar name 276is not a directory, 277or a path prefix of 278.Ar special 279is not a directory. 280.It Bq Er EINVAL 281An argument given was invalid. 282.It Bq Er EBUSY 283Another process currently holds a reference to 284.Fa dir . 285.It Bq Er EFAULT 286.Fa dir 287points outside the process's allocated address space. 288.It Bq Er EOPNOTSUPP 289.Fa type 290is not supported by the kernel. 291.El 292.Pp 293The following errors can occur for a 294.Dq ufs 295filesystem mount: 296.Bl -tag -width [ENOTBLK] 297.It Bq Er ENODEV 298A component of ufs_args 299.Fa fspec 300does not exist. 301.It Bq Er ENOTBLK 302.Fa fspec 303is not a block device. 304.It Bq Er ENXIO 305The major device number of 306.Fa fspec 307is out of range (this indicates no device driver exists 308for the associated hardware). 309.It Bq Er EBUSY 310.Fa fspec 311is already mounted. 312.It Bq Er EINVAL 313The super block for the filesystem had a bad magic number, an out of range 314block size, or an invalid combination of flags. 315.It Bq Er ENOMEM 316Not enough memory was available to read the cylinder 317group information for the filesystem. 318.It Bq Er EIO 319An I/O error occurred while reading the super block or 320cylinder group information. 321.It Bq Er EFAULT 322.Fa fspec 323points outside the process's allocated address space. 324.It Bq Er EROFS 325The filesystem was not unmounted cleanly and 326.Dv MNT_FORCE 327was not specified. 328.It Bq Er EROFS 329An attempt was made to mount a 330.Bx 4.2 331filesystem without the 332.Dv MNT_RDONLY 333flag. 334.El 335.Pp 336The following errors can occur for an 337.Em NFS 338filesystem mount: 339.Bl -tag -width [ETIMEDOUT] 340.It Bq Er ETIMEDOUT 341.Em NFS 342timed out trying to contact the server. 343.It Bq Er EFAULT 344Some part of the information described by nfs_args 345points outside the process's allocated address space. 346.El 347.Pp 348The following errors can occur for a 349.Em mfs 350filesystem mount: 351.Bl -tag -width [EMFILE] 352.It Bq Er EMFILE 353No space remains in the mount table. 354.It Bq Er EINVAL 355The super block for the filesystem had a bad magic 356number or an out of range block size. 357.It Bq Er ENOMEM 358Not enough memory was available to read the cylinder 359group information for the filesystem. 360.It Bq Er EIO 361A paging error occurred while reading the super block or 362cylinder group information. 363.It Bq Er EFAULT 364.Em Name 365points outside the process's allocated address space. 366.El 367.Pp 368.Fn unmount 369may fail with one of the following errors: 370.Bl -tag -width [ENAMETOOLONG] 371.It Bq Er EPERM 372The caller is not the superuser. 373.It Bq Er ENOTDIR 374A component of the path is not a directory. 375.It Bq Er EINVAL 376An argument given was invalid. 377.It Bq Er ENAMETOOLONG 378A component of a pathname exceeded 379.Dv {NAME_MAX} 380characters, or an entire path name exceeded 381.Dv {PATH_MAX} 382characters. 383.It Bq Er ELOOP 384Too many symbolic links were encountered in translating the pathname. 385.It Bq Er EINVAL 386The requested directory is not in the mount table. 387.It Bq Er EBUSY 388A process is holding a reference to a file located 389on the filesystem. 390.It Bq Er EIO 391An I/O error occurred while writing cached filesystem information. 392.It Bq Er EFAULT 393.Fa dir 394points outside the process's allocated address space. 395.El 396.Sh SEE ALSO 397.Xr statfs 2 , 398.Xr mfs 8 , 399.Xr mount 8 , 400.Xr umount 8 401.Sh HISTORY 402The 403.Fn mount 404and 405.Fn unmount 406system calls first appeared in 407.At v1 . 408The 409.Fa flags 410argument is supported by 411.Fn mount 412since 413.At v5 414and by 415.Fn unmount 416since 417.Bx 4.3 Reno . 418The current calling convention involving 419.Fa type 420and 421.Fa data 422arguments was introduced by 423.Bx 4.3 Reno 424as well. 425.Sh BUGS 426Some of the error codes need translation to more obvious messages. 427