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