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