xref: /csrg-svn/lib/libc/sys/mount.2 (revision 63767)
1*63767Sbostic.\" Copyright (c) 1980, 1989, 1993
2*63767Sbostic.\"	The Regents of the University of California.  All rights reserved.
320083Smckusick.\"
443568Strent.\" %sccs.include.redist.man%
520083Smckusick.\"
6*63767Sbostic.\"     @(#)mount.2	8.1 (Berkeley) 07/11/93
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
7863766Smckusickargument defines the type of the filesystem.
7963766SmckusickThe types of filesystems known to the system are defined in
8047208Scael.Aq Pa sys/mount.h .
8147208Scael.Fa Data
8238648Smckusickis a pointer to a structure that contains the type
8338648Smckusickspecific arguments to mount.
8463766SmckusickThe currently supported types of filesystems and
8538648Smckusicktheir type specific data are:
8647208Scael.Pp
8747208Scael.Dv MOUNT_UFS
8847450Scael.Bd -literal -offset indent -compact
8938648Smckusickstruct ufs_args {
9047450Scael      char	*fspec;  /* Block special file to mount */
9147450Scael      int	exflags; /* export related flags */
9247450Scael      uid_t	exroot;  /* mapping for root uid */
9338648Smckusick};
9447208Scael.Ed
9547208Scael.Pp
9647208Scael.Dv MOUNT_NFS
9747450Scael.Bd -literal -offset indent -compact
9838648Smckusickstruct nfs_args {
9947450Scael      struct sockaddr_in *addr; /* file server address */
10047450Scael      nfsv2fh_t *fh;       /* File handle to be mounted */
10147450Scael      int       flags;     /* flags */
10247450Scael      int       wsize;     /* write size in bytes */
10347450Scael      int       rsize;     /* read size in bytes */
10447450Scael      int       timeo;     /* initial timeout 0.1 secs */
10547450Scael      int       retrans;   /* times to retry send */
10647450Scael      char      *hostname; /* server's name */
10738648Smckusick};
10847208Scael.Ed
10947208Scael.Pp
11047208Scael.Dv MOUNT_MFS
11147450Scael.Bd -literal -offset indent -compact
11239331Smckusickstruct mfs_args {
11347450Scael      char	*name;	/* name of backing process */
11463766Smckusick      caddr_t	base;	/* base address of the filesystem */
11563766Smckusick      u_long	size;	/* size of the filesystem */
11639331Smckusick};
11747208Scael.Ed
11847208Scael.Pp
11938648SmckusickThe
12047208Scael.Fn umount
12147208Scaelfunction call disassociates the filesystem from the specified
12247208Scaelmount point
12347208Scael.Fa dir .
12447208Scael.Pp
12547208ScaelThe
12647208Scael.Fa flags
12763766Smckusickargument may specify
12863766Smckusick.Dv MNT_FORCE
12963766Smckusickto specify that the filesystem should be forcibly unmounted even if files are
13038648Smckusickstill active.
13139502SmckusickActive special devices continue to work,
13239502Smckusickbut any further accesses to any other active files result in errors
13363766Smckusickeven if the filesystem is later remounted.
13447208Scael.Sh RETURN VALUES
13547208ScaelThe
13647208Scael.Fn mount
13747208Scaelreturns the value 0 if the mount was successful, otherwise -1 is returned
13847208Scaeland the variable
13947208Scael.Va errno
14047208Scaelis set to indicate the error.
14147208Scael.Pp
14247208Scael.Nm Umount
14347208Scaelreturns the value 0 if the umount succeeded; otherwise -1 is returned
14447208Scaeland the variable
14547208Scael.Va errno
14647208Scaelis set to indicate the error.
14747208Scael.Sh ERRORS
14847208Scael.Fn Mount
14920084Smckusickwill fail when one of the following occurs:
15047208Scael.Bl -tag -width [ENOTBLK]
15147208Scael.It Bq Er EPERM
15238648SmckusickThe caller is not the super-user.
15347208Scael.It Bq Er ENAMETOOLONG
15438648SmckusickA component of a pathname exceeded 255 characters,
15538648Smckusickor the entire length of a path name exceeded 1023 characters.
15647208Scael.It Bq Er ELOOP
15738648SmckusickToo many symbolic links were encountered in translating a pathname.
15847208Scael.It Bq Er ENOENT
15947208ScaelA component of
16047208Scael.Fa dir
16147208Scaeldoes not exist.
16247208Scael.It Bq Er ENOTDIR
16347208ScaelA component of
16447208Scael.Ar name
16547208Scaelis not a directory,
16647208Scaelor a path prefix of
16747208Scael.Ar special
16847208Scaelis not a directory.
16947208Scael.It Bq Er EINVAL
17038648SmckusickA pathname contains a character with the high-order bit set.
17147208Scael.It Bq Er EBUSY
17238648SmckusickAnother process currently holds a reference to
17347208Scael.Fa dir .
17447208Scael.It Bq Er EFAULT
17547208Scael.Fa Dir
17647208Scaelpoints outside the process's allocated address space.
17747208Scael.El
17847208Scael.Pp
17938648SmckusickThe following errors can occur for a
18047208Scael.Em ufs
18163766Smckusickfilesystem mount:
18247208Scael.Bl -tag -width [ENOTBLK]
18347208Scael.It Bq Er ENODEV
18447208ScaelA component of ufs_args
18547208Scael.Ar fspec
18647208Scaeldoes not exist.
18747208Scael.It Bq Er ENOTBLK
18847208Scael.Ar Fspec
18920084Smckusickis not a block device.
19047208Scael.It Bq Er ENXIO
19120084SmckusickThe major device number of
19247208Scael.Ar fspec
19320084Smckusickis out of range (this indicates no device driver exists
19420084Smckusickfor the associated hardware).
19547208Scael.It Bq Er EBUSY
19647208Scael.Ar Fspec
19747208Scaelis already mounted.
19847208Scael.It Bq Er EMFILE
19938648SmckusickNo space remains in the mount table.
20047208Scael.It Bq Er EINVAL
20163766SmckusickThe super block for the filesystem had a bad magic
20221003Smckusicknumber or an out of range block size.
20347208Scael.It Bq Er ENOMEM
20420084SmckusickNot enough memory was available to read the cylinder
20563766Smckusickgroup information for the filesystem.
20647208Scael.It Bq Er EIO
20724439SmckusickAn I/O error occurred while reading the super block or
20820084Smckusickcylinder group information.
20947208Scael.It Bq Er EFAULT
21047208Scael.Ar Fspec
21147208Scaelpoints outside the process's allocated address space.
21247208Scael.El
21347208Scael.Pp
21438648SmckusickThe following errors can occur for a
21547208Scael.Em nfs
21663766Smckusickfilesystem mount:
21747208Scael.Bl -tag -width [ENOTBLK]
21847208Scael.It Bq Er ETIMEDOUT
21947208Scael.Em Nfs
22038648Smckusicktimed out trying to contact the server.
22147208Scael.It Bq Er EFAULT
22238648SmckusickSome part of the information described by nfs_args
22338648Smckusickpoints outside the process's allocated address space.
22447208Scael.El
22547208Scael.Pp
22639331SmckusickThe following errors can occur for a
22747208Scael.Em mfs
22863766Smckusickfilesystem mount:
22947208Scael.Bl -tag -width [ENOTBLK]
23047208Scael.It Bq Er EMFILE
23139331SmckusickNo space remains in the mount table.
23247208Scael.It Bq Er EINVAL
23363766SmckusickThe super block for the filesystem had a bad magic
23439331Smckusicknumber or an out of range block size.
23547208Scael.It Bq Er ENOMEM
23639331SmckusickNot enough memory was available to read the cylinder
23763766Smckusickgroup information for the filesystem.
23847208Scael.It Bq Er EIO
23939331SmckusickAn paging error occurred while reading the super block or
24039331Smckusickcylinder group information.
24147208Scael.It Bq Er EFAULT
24247208Scael.Em Name
24347208Scaelpoints outside the process's allocated address space.
24447208Scael.El
24547208Scael.Pp
24647450Scael.Nm Umount
24720084Smckusickmay fail with one of the following errors:
24847208Scael.Bl -tag -width [ENOTBLK]
24947208Scael.It Bq Er EPERM
25038648SmckusickThe caller is not the super-user.
25147208Scael.It Bq Er ENOTDIR
25238648SmckusickA component of the path is not a directory.
25347208Scael.It Bq Er EINVAL
25421003SmckusickThe pathname contains a character with the high-order bit set.
25547208Scael.It Bq Er ENAMETOOLONG
25621003SmckusickA component of a pathname exceeded 255 characters,
25721003Smckusickor an entire path name exceeded 1023 characters.
25847208Scael.It Bq Er ELOOP
25921003SmckusickToo many symbolic links were encountered in translating the pathname.
26047208Scael.It Bq Er EINVAL
26138648SmckusickThe requested directory is not in the mount table.
26247208Scael.It Bq Er EBUSY
26320084SmckusickA process is holding a reference to a file located
26463766Smckusickon the filesystem.
26547208Scael.It Bq Er EIO
26663766SmckusickAn I/O error occurred while writing cached filesystem information.
26747208Scael.It Bq Er EFAULT
26847208Scael.Fa Dir
26947208Scaelpoints outside the process's allocated address space.
27047208Scael.El
27147208Scael.Pp
27247208ScaelA
27347208Scael.Em ufs
27447208Scaelor
27547208Scael.Em mfs
27647208Scaelmount can also fail if the maximum number of filesystems are currently
27747208Scaelmounted.
27847208Scael.Sh SEE ALSO
27947208Scael.Xr mount 8 ,
28047208Scael.Xr umount 8 ,
28147208Scael.Xr mfs 8
28247208Scael.Sh BUGS
28321003SmckusickSome of the error codes need translation to more obvious messages.
28447208Scael.Sh HISTORY
28547208Scael.Fn Mount
28647208Scaeland
28747208Scael.Fn umount
28847208Scaelfunction calls appeared in Version 6 AT&T UNIX.
289