1.\" $NetBSD: mount.2,v 1.36 2006/02/24 20:49:38 wiz 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. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)mount.2 8.3 (Berkeley) 5/24/95 31.\" 32.Dd February 11, 2006 33.Dt MOUNT 2 34.Os 35.Sh NAME 36.Nm mount , 37.Nm unmount 38.Nd mount or dismount a file system 39.Sh LIBRARY 40.Lb libc 41.Sh SYNOPSIS 42.In sys/param.h 43.In sys/mount.h 44.Ft int 45.Fn mount "const char *type" "const char *dir" "int flags" "void *data" 46.Ft int 47.Fn unmount "const char *dir" "int flags" 48.Sh DESCRIPTION 49The 50.Fn mount 51function grafts 52a file system object onto the system file tree 53at the point 54.Ar dir . 55The argument 56.Ar data 57describes the file system object to be mounted. 58The argument 59.Ar type 60tells the kernel how to interpret 61.Ar data 62(See 63.Ar type 64below). 65The contents of the file system 66become available through the new mount point 67.Ar dir . 68Any files in 69.Ar dir 70at the time 71of a successful mount are swept under the carpet so to speak, and 72are unavailable until the file system is unmounted. 73.Pp 74The following 75.Ar flags 76may be specified to 77suppress default semantics which affect file system access. 78.Bl -tag -width MNT_SYNCHRONOUS 79.It Dv MNT_RDONLY 80The file system should be treated as read-only; 81even the super-user may not write on it. 82.It Dv MNT_NOEXEC 83Do not allow files to be executed from the file system. 84.It Dv MNT_NOSUID 85Do not honor setuid or setgid bits on files when executing them. 86.It Dv MNT_NODEV 87Do not interpret special files on the file system. 88.It Dv MNT_UNION 89Union with underlying filesystem instead of obscuring it. 90.It Dv MNT_SYNCHRONOUS 91All I/O to the file system should be done synchronously. 92.It Dv MNT_ASYNC 93All I/O to the file system should be done asynchronously. 94.It Dv MNT_NOCOREDUMP 95Do not allow programs to dump core files on the file system. 96.It Dv MNT_NOATIME 97Never update access time in the file system. 98.It Dv MNT_SYMPERM 99Recognize the permission of symbolic link when reading or traversing. 100.It Dv MNT_NODEVMTIME 101Never update modification time of device files. 102.It Dv MNT_SOFTDEP 103Use soft dependencies. 104.El 105.Pp 106The 107.Dv MNT_UPDATE 108and the 109.Dv MNT_GETARGS 110flags indicate that the mount command is being applied 111to an already mounted file system. 112The 113.Dv MNT_UPDATE 114flag allows the mount flags to be changed without requiring 115that the file system be unmounted and remounted. 116Some file systems may not allow all flags to be changed. 117For example, 118most file systems will not allow a change from read-write to read-only. 119The 120.Dv MNT_GETARGS 121flag does not alter any of the mounted filesystem's properties, 122but returns the filesystem-specific arguments for the currently mounted 123filesystem. 124.Pp 125The 126.Fa type 127argument defines the type of the file system. 128The types of file systems known to the system are defined in 129.Aq Pa sys/mount.h . 130.\" XXX from lite-2: 131.\" The types of filesystems known to the system can be obtained with 132.\" .Xr sysctl 8 133.\" by using the command: 134.\" .Bd -literal -offset indent 135.\" sysctl vfs 136.\" .Ed 137.\" .Pp 138.Fa data 139is a pointer to a structure that contains the type 140specific arguments to mount. 141The currently supported types of file systems and 142their type specific data are: 143.Pp 144.Dv MOUNT_FFS 145.Bd -literal -offset indent -compact 146struct ufs_args { 147 char *fspec; /* block special file to mount */ 148 struct export_args export; /* network export information */ 149}; 150.Ed 151.Pp 152.Dv MOUNT_NFS 153.Bd -literal -offset indent -compact 154struct nfs_args { 155 int version; /* args structure version */ 156 struct sockaddr *addr; /* file server address */ 157 int addrlen; /* length of address */ 158 int sotype; /* Socket type */ 159 int proto; /* and Protocol */ 160 u_char *fh; /* File handle to be mounted */ 161 int fhsize; /* Size, in bytes, of fh */ 162 int flags; /* flags */ 163 int wsize; /* write size in bytes */ 164 int rsize; /* read size in bytes */ 165 int readdirsize; /* readdir size in bytes */ 166 int timeo; /* initial timeout in .1 secs */ 167 int retrans; /* times to retry send */ 168 int maxgrouplist; /* Max. size of group list */ 169 int readahead; /* # of blocks to readahead */ 170 int leaseterm; /* Term (sec) of lease */ 171 int deadthresh; /* Retrans threshold */ 172 char *hostname; /* server's name */ 173}; 174.Ed 175.Pp 176.Dv MOUNT_MFS 177.Bd -literal -offset indent -compact 178struct mfs_args { 179 char *fspec; /* name to export for statfs */ 180 struct export_args export; /* if we can export an MFS */ 181 caddr_t base; /* base of file system in mem */ 182 u_long size; /* size of file system */ 183}; 184.Ed 185.\" XXX from lite-2: 186.\" The format for these argument structures is described in the 187.\" manual page for each filesystem. 188.\" By convention filesystem manual pages are named 189.\" by prefixing ``mount_'' to the name of the filesystem as returned by 190.\" .Xr sysctl 8 . 191.\" Thus the 192.\" .Nm NFS 193.\" filesystem is described by the 194.\" .Xr mount_nfs 8 195.\" manual page. 196.Pp 197The 198.Fn unmount 199function call disassociates the file system from the specified 200mount point 201.Fa dir . 202.Pp 203The 204.Fa flags 205argument may specify 206.Dv MNT_FORCE 207to specify that the file system should be forcibly unmounted even if files are 208still active. 209Active special devices continue to work, 210but any further accesses to any other active files result in errors 211even if the file system is later remounted. 212.Sh RETURN VALUES 213.Fn mount 214returns the value 0 if the mount was successful, otherwise \-1 is returned 215and the variable 216.Va errno 217is set to indicate the error. 218.Pp 219.Fn unmount 220returns the value 0 if the unmount succeeded; otherwise \-1 is returned 221and the variable 222.Va errno 223is set to indicate the error. 224.Sh ERRORS 225.Fn mount 226will fail when one of the following occurs: 227.Bl -tag -width Er 228.It Bq Er EPERM 229The caller is not the super-user. 230.It Bq Er ENAMETOOLONG 231A component of a pathname exceeded 232.Dv {NAME_MAX} 233characters, or an entire path name exceeded 234.Dv {PATH_MAX} 235characters. 236.It Bq Er ELOOP 237Too many symbolic links were encountered in translating a pathname. 238.It Bq Er ENOENT 239A component of 240.Fa dir 241does not exist. 242.It Bq Er ENOTDIR 243A component of 244.Ar name 245is not a directory, 246or a path prefix of 247.Ar special 248is not a directory. 249.It Bq Er EBUSY 250Another process currently holds a reference to 251.Fa dir . 252.It Bq Er EFAULT 253.Fa dir 254points outside the process's allocated address space. 255.El 256.Pp 257The following errors can occur for a 258.Em ufs 259file system mount: 260.Bl -tag -width Er 261.It Bq Er ENODEV 262A component of ufs_args 263.Ar fspec 264does not exist. 265.It Bq Er ENOTBLK 266.Ar Fspec 267is not a block device. 268.It Bq Er ENXIO 269The major device number of 270.Ar fspec 271is out of range (this indicates no device driver exists 272for the associated hardware). 273.It Bq Er EBUSY 274.Ar Fspec 275is already mounted. 276.It Bq Er EMFILE 277No space remains in the mount table. 278.It Bq Er EINVAL 279The super block for the file system had a bad magic 280number or an out of range block size. 281.It Bq Er ENOMEM 282Not enough memory was available to read the cylinder 283group information for the file system. 284.It Bq Er EIO 285An I/O error occurred while reading the super block or 286cylinder group information. 287.It Bq Er EFAULT 288.Ar Fspec 289points outside the process's allocated address space. 290.El 291.Pp 292The following errors can occur for a 293.Em nfs 294file system mount: 295.Bl -tag -width Er 296.It Bq Er ETIMEDOUT 297.Em Nfs 298timed out trying to contact the server. 299.It Bq Er EFAULT 300Some part of the information described by nfs_args 301points outside the process's allocated address space. 302.El 303.Pp 304The following errors can occur for a 305.Em mfs 306file system mount: 307.Bl -tag -width Er 308.It Bq Er EMFILE 309No space remains in the mount table. 310.It Bq Er EINVAL 311The super block for the file system had a bad magic 312number or an out of range block size. 313.It Bq Er ENOMEM 314Not enough memory was available to read the cylinder 315group information for the file system. 316.It Bq Er EIO 317A paging error occurred while reading the super block or 318cylinder group information. 319.It Bq Er EFAULT 320.Em Name 321points outside the process's allocated address space. 322.El 323.Pp 324.Fn unmount 325may fail with one of the following errors: 326.Bl -tag -width Er 327.It Bq Er EPERM 328The caller is not the super-user. 329.It Bq Er ENOTDIR 330A component of the path is not a directory. 331.It Bq Er ENAMETOOLONG 332A component of a pathname exceeded 333.Dv {NAME_MAX} 334characters, or an entire path name exceeded 335.Dv {PATH_MAX} 336characters. 337.It Bq Er ELOOP 338Too many symbolic links were encountered in translating the pathname. 339.It Bq Er EINVAL 340The requested directory is not in the mount table. 341.It Bq Er EBUSY 342A process is holding a reference to a file located 343on the file system. 344.It Bq Er EIO 345An I/O error occurred while writing cached file system information. 346.It Bq Er EFAULT 347.Fa dir 348points outside the process's allocated address space. 349.El 350.Pp 351A 352.Em ufs 353or 354.Em mfs 355mount can also fail if the maximum number of file systems are currently 356mounted. 357.Sh SEE ALSO 358.Xr getvfsstat 2 , 359.Xr getmntinfo 3 , 360.Xr symlink 7 , 361.Xr mount 8 , 362.Xr sysctl 8 , 363.Xr umount 8 364.Sh HISTORY 365The 366.Fn mount 367and 368.Fn umount 369(now 370.Fn unmount ) 371function calls appeared in 372.At v6 . 373.Sh BUGS 374Some of the error codes need translation to more obvious messages. 375