163767Sbostic.\" Copyright (c) 1980, 1989, 1993 263767Sbostic.\" The Regents of the University of California. All rights reserved. 320083Smckusick.\" 443568Strent.\" %sccs.include.redist.man% 520083Smckusick.\" 6*69676Smckusick.\" @(#)mount.2 8.3 (Berkeley) 05/24/95 738648Smckusick.\" 847208Scael.Dd 947208Scael.Dt MOUNT 2 1047208Scael.Os BSD 4 1147208Scael.Sh NAME 1247208Scael.Nm mount , 1347208Scael.Nm unmount 1447208Scael.Nd mount or dismount a filesystem 1547208Scael.Sh SYNOPSIS 1663766Smckusick.Fd #include <sys/param.h> 1747208Scael.Fd #include <sys/mount.h> 1847208Scael.Ft int 1947208Scael.Fn mount "int type" "const char *dir" "int flags" "caddr_t data" 2047208Scael.Ft int 2147208Scael.Fn unmount "const char *dir" "int flags" 2247208Scael.Sh DESCRIPTION 2320083SmckusickThe 2447208Scael.Fn mount 2547208Scaelfunction grafts 2647208Scaela filesystem object onto the system file tree 2747208Scaelat the point 2847208Scael.Ar dir . 2947208ScaelThe argument 3047208Scael.Ar data 3147208Scaeldescribes the filesystem object to be mounted. 3247208ScaelThe argument 3347208Scael.Ar type 3447208Scaeltells the kernel how to interpret 3547208Scael.Ar data 3647208Scael(See 3747208Scael.Ar type 3847208Scaelbelow). 3947208ScaelThe contents of the filesystem 4047208Scaelbecome available through the new mount point 4147208Scael.Ar dir . 4247208ScaelAny files in 4347208Scael.Ar dir 4447208Scaelat the time 4547208Scaelof a successful mount are swept under the carpet so to speak, and 4647208Scaelare unavailable until the filesystem is unmounted. 4747208Scael.Pp 4847208ScaelThe following 4947208Scael.Ar flags 5047208Scaelmay be specified to 5147208Scaelsuppress default semantics which affect filesystem access. 5263766Smckusick.Bl -tag -width MNT_SYNCHRONOUS 5363766Smckusick.It Dv MNT_RDONLY 5463766SmckusickThe filesystem should be treated as read-only; 5547208ScaelEven the super-user may not write on it. 5663766Smckusick.It Dv MNT_NOEXEC 5763766SmckusickDo not allow files to be executed from the filesystem. 5863766Smckusick.It Dv MNT_NOSUID 5939331SmckusickDo not honor setuid or setgid bits on files when executing them. 6063766Smckusick.It Dv MNT_NODEV 6163766SmckusickDo not interpret special files on the filesystem. 6263766Smckusick.It Dv MNT_SYNCHRONOUS 6363766SmckusickAll I/O to the filesystem should be done synchronously. 6447208Scael.El 6547208Scael.Pp 6647208ScaelThe flag 6763766Smckusick.Dv MNT_UPDATE 6847208Scaelindicates that the mount command is being applied 6963766Smckusickto an already mounted filesystem. 7039467SmckusickThis allows the mount flags to be changed without requiring 7163766Smckusickthat the filesystem be unmounted and remounted. 7263766SmckusickSome filesystems may not allow all flags to be changed. 7339467SmckusickFor example, 7463766Smckusickmost filesystems will not allow a change from read-write to read-only. 7547208Scael.Pp 7638648SmckusickThe 7747208Scael.Fa type 78*69676Smckusickargument names the filesystem. 79*69676SmckusickThe types of filesystems known to the system can be obtained with 80*69676Smckusick.Xr sysctl 8 81*69676Smckusickby using the command: 82*69676Smckusick.Bd -literal -offset indent 83*69676Smckusicksysctl vfs 84*69676Smckusick.Ed 85*69676Smckusick.Pp 8647208Scael.Fa Data 8738648Smckusickis a pointer to a structure that contains the type 8838648Smckusickspecific arguments to mount. 89*69676SmckusickThe format for these argument structures is described in the 90*69676Smckusickmanual page for each filesystem. 91*69676SmckusickBy convention filesystem manual pages are named 92*69676Smckusickby prefixing ``mount_'' to the name of the filesystem as returned by 93*69676Smckusick.Xr sysctl 8 . 94*69676SmckusickThus the 95*69676Smckusick.Nm NFS 96*69676Smckusickfilesystem is described by the 97*69676Smckusick.Xr mount_nfs 8 98*69676Smckusickmanual page. 9947208Scael.Pp 10038648SmckusickThe 10147208Scael.Fn umount 10247208Scaelfunction call disassociates the filesystem from the specified 10347208Scaelmount point 10447208Scael.Fa dir . 10547208Scael.Pp 10647208ScaelThe 10747208Scael.Fa flags 10863766Smckusickargument may specify 10963766Smckusick.Dv MNT_FORCE 11063766Smckusickto specify that the filesystem should be forcibly unmounted even if files are 11138648Smckusickstill active. 11239502SmckusickActive special devices continue to work, 11339502Smckusickbut any further accesses to any other active files result in errors 11463766Smckusickeven if the filesystem is later remounted. 11547208Scael.Sh RETURN VALUES 11647208ScaelThe 11747208Scael.Fn mount 11847208Scaelreturns the value 0 if the mount was successful, otherwise -1 is returned 11947208Scaeland the variable 12047208Scael.Va errno 12147208Scaelis set to indicate the error. 12247208Scael.Pp 12347208Scael.Nm Umount 12447208Scaelreturns the value 0 if the umount succeeded; otherwise -1 is returned 12547208Scaeland the variable 12647208Scael.Va errno 12747208Scaelis set to indicate the error. 12847208Scael.Sh ERRORS 12947208Scael.Fn Mount 13020084Smckusickwill fail when one of the following occurs: 13147208Scael.Bl -tag -width [ENOTBLK] 13247208Scael.It Bq Er EPERM 13338648SmckusickThe caller is not the super-user. 13447208Scael.It Bq Er ENAMETOOLONG 13538648SmckusickA component of a pathname exceeded 255 characters, 13638648Smckusickor the entire length of a path name exceeded 1023 characters. 13747208Scael.It Bq Er ELOOP 13838648SmckusickToo many symbolic links were encountered in translating a pathname. 13947208Scael.It Bq Er ENOENT 14047208ScaelA component of 14147208Scael.Fa dir 14247208Scaeldoes not exist. 14347208Scael.It Bq Er ENOTDIR 14447208ScaelA component of 14547208Scael.Ar name 14647208Scaelis not a directory, 14747208Scaelor a path prefix of 14847208Scael.Ar special 14947208Scaelis not a directory. 15047208Scael.It Bq Er EINVAL 15138648SmckusickA pathname contains a character with the high-order bit set. 15247208Scael.It Bq Er EBUSY 15338648SmckusickAnother process currently holds a reference to 15447208Scael.Fa dir . 15547208Scael.It Bq Er EFAULT 15647208Scael.Fa Dir 15747208Scaelpoints outside the process's allocated address space. 15847208Scael.El 15947208Scael.Pp 16038648SmckusickThe following errors can occur for a 16147208Scael.Em ufs 16263766Smckusickfilesystem mount: 16347208Scael.Bl -tag -width [ENOTBLK] 16447208Scael.It Bq Er ENODEV 16547208ScaelA component of ufs_args 16647208Scael.Ar fspec 16747208Scaeldoes not exist. 16847208Scael.It Bq Er ENOTBLK 16947208Scael.Ar Fspec 17020084Smckusickis not a block device. 17147208Scael.It Bq Er ENXIO 17220084SmckusickThe major device number of 17347208Scael.Ar fspec 17420084Smckusickis out of range (this indicates no device driver exists 17520084Smckusickfor the associated hardware). 17647208Scael.It Bq Er EBUSY 17747208Scael.Ar Fspec 17847208Scaelis already mounted. 17947208Scael.It Bq Er EMFILE 18038648SmckusickNo space remains in the mount table. 18147208Scael.It Bq Er EINVAL 18263766SmckusickThe super block for the filesystem had a bad magic 18321003Smckusicknumber or an out of range block size. 18447208Scael.It Bq Er ENOMEM 18520084SmckusickNot enough memory was available to read the cylinder 18663766Smckusickgroup information for the filesystem. 18747208Scael.It Bq Er EIO 18824439SmckusickAn I/O error occurred while reading the super block or 18920084Smckusickcylinder group information. 19047208Scael.It Bq Er EFAULT 19147208Scael.Ar Fspec 19247208Scaelpoints outside the process's allocated address space. 19347208Scael.El 19447208Scael.Pp 19538648SmckusickThe following errors can occur for a 19647208Scael.Em nfs 19763766Smckusickfilesystem mount: 19847208Scael.Bl -tag -width [ENOTBLK] 19947208Scael.It Bq Er ETIMEDOUT 20047208Scael.Em Nfs 20138648Smckusicktimed out trying to contact the server. 20247208Scael.It Bq Er EFAULT 20338648SmckusickSome part of the information described by nfs_args 20438648Smckusickpoints outside the process's allocated address space. 20547208Scael.El 20647208Scael.Pp 20739331SmckusickThe following errors can occur for a 20847208Scael.Em mfs 20963766Smckusickfilesystem mount: 21047208Scael.Bl -tag -width [ENOTBLK] 21147208Scael.It Bq Er EMFILE 21239331SmckusickNo space remains in the mount table. 21347208Scael.It Bq Er EINVAL 21463766SmckusickThe super block for the filesystem had a bad magic 21539331Smckusicknumber or an out of range block size. 21647208Scael.It Bq Er ENOMEM 21739331SmckusickNot enough memory was available to read the cylinder 21863766Smckusickgroup information for the filesystem. 21947208Scael.It Bq Er EIO 22065100SmckusickA paging error occurred while reading the super block or 22139331Smckusickcylinder group information. 22247208Scael.It Bq Er EFAULT 22347208Scael.Em Name 22447208Scaelpoints outside the process's allocated address space. 22547208Scael.El 22647208Scael.Pp 22747450Scael.Nm Umount 22820084Smckusickmay fail with one of the following errors: 22947208Scael.Bl -tag -width [ENOTBLK] 23047208Scael.It Bq Er EPERM 23138648SmckusickThe caller is not the super-user. 23247208Scael.It Bq Er ENOTDIR 23338648SmckusickA component of the path is not a directory. 23447208Scael.It Bq Er EINVAL 23521003SmckusickThe pathname contains a character with the high-order bit set. 23647208Scael.It Bq Er ENAMETOOLONG 23721003SmckusickA component of a pathname exceeded 255 characters, 23821003Smckusickor an entire path name exceeded 1023 characters. 23947208Scael.It Bq Er ELOOP 24021003SmckusickToo many symbolic links were encountered in translating the pathname. 24147208Scael.It Bq Er EINVAL 24238648SmckusickThe requested directory is not in the mount table. 24347208Scael.It Bq Er EBUSY 24420084SmckusickA process is holding a reference to a file located 24563766Smckusickon the filesystem. 24647208Scael.It Bq Er EIO 24763766SmckusickAn I/O error occurred while writing cached filesystem information. 24847208Scael.It Bq Er EFAULT 24947208Scael.Fa Dir 25047208Scaelpoints outside the process's allocated address space. 25147208Scael.El 25247208Scael.Pp 25347208ScaelA 25447208Scael.Em ufs 25547208Scaelor 25647208Scael.Em mfs 25747208Scaelmount can also fail if the maximum number of filesystems are currently 25847208Scaelmounted. 25947208Scael.Sh SEE ALSO 26047208Scael.Xr mount 8 , 26147208Scael.Xr umount 8 , 262*69676Smckusick.Xr sysctl 8 26347208Scael.Sh BUGS 26421003SmckusickSome of the error codes need translation to more obvious messages. 26547208Scael.Sh HISTORY 26647208Scael.Fn Mount 26747208Scaeland 26847208Scael.Fn umount 26947208Scaelfunction calls appeared in Version 6 AT&T UNIX. 270