xref: /original-bsd/lib/libc/sys/mount.2 (revision 14054b48)
1.\" Copyright (c) 1980, 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)mount.2	6.11 (Berkeley) 03/10/91
7.\"
8.Dd
9.Dt MOUNT 2
10.Os BSD 4
11.Sh NAME
12.Nm mount ,
13.Nm unmount
14.Nd mount or dismount a filesystem
15.Sh SYNOPSIS
16.Fd #include <sys/mount.h>
17.Ft int
18.Fn mount "int type" "const char *dir" "int flags" "caddr_t data"
19.Ft int
20.Fn unmount "const char *dir" "int flags"
21.Sh DESCRIPTION
22The
23.Fn mount
24function grafts
25a filesystem object onto the system file tree
26at the point
27.Ar dir .
28The argument
29.Ar data
30describes the filesystem object to be mounted.
31The argument
32.Ar type
33tells the kernel how to interpret
34.Ar data
35(See
36.Ar type
37below).
38The contents of the filesystem
39become available through the new mount point
40.Ar dir .
41Any files in
42.Ar dir
43at the time
44of a successful mount are swept under the carpet so to speak, and
45are unavailable until the filesystem is unmounted.
46.Pp
47The following
48.Ar flags
49may be specified to
50suppress default semantics which affect filesystem access.
51.Bl -tag -width M_SYNCHRONOUS
52.It Dv M_RDONLY
53The file system should be treated as read-only;
54Even the super-user may not write on it.
55.It Dv M_NOEXEC
56Do not allow files to be executed from the file system.
57.It Dv M_NOSUID
58Do not honor setuid or setgid bits on files when executing them.
59.It Dv M_NODEV
60Do not interpret special files on the file system.
61.It Dv M_SYNCHRONOUS
62All I/O to the file system should be done synchronously.
63.El
64.Pp
65The flag
66.Dv M_UPDATE
67indicates that the mount command is being applied
68to an already mounted file system.
69This allows the mount flags to be changed without requiring
70that the file system be unmounted and remounted.
71Some file systems may not allow all flags to be changed.
72For example,
73most file systems will not allow a change from read-write to read-only.
74.Pp
75The
76.Fa type
77argument defines the type of the file system.
78The types of file systems known to the system are defined in
79.Aq Pa sys/mount.h .
80.Fa Data
81is a pointer to a structure that contains the type
82specific arguments to mount.
83The currently supported types of file systems and
84their type specific data are:
85.Pp
86.Dv MOUNT_UFS
87.Bd -literal -compact -offset indent
88struct ufs_args {
89	char	*fspec;	/* Block special file to mount */
90	int	exflags;	/* export related flags */
91	uid_t	exroot;	/* mapping for root uid */
92};
93.Ed
94.Pp
95.Dv MOUNT_NFS
96.Bd -literal -compact -offset indent
97struct nfs_args {
98	struct	sockaddr_in *addr;	/* file server address */
99	nfsv2fh_t	*fh;	/* File handle to be mounted */
100	int	flags;	/* flags */
101	int	wsize;	/* write size in bytes */
102	int	rsize;	/* read size in bytes */
103	int	timeo;	/* initial timeout in 0.1 secs */
104	int	retrans;	/* times to retry send */
105	char	*hostname;	/* server's name */
106};
107.Ed
108.Pp
109.Dv MOUNT_MFS
110.Bd -literal -compact -offset indent
111struct mfs_args {
112	char	*name;	/* name of backing process */
113	caddr_t	base;	/* base address of the file system */
114	u_long	size;	/* size of the file system */
115};
116.Ed
117.Pp
118The
119.Fn umount
120function call disassociates the filesystem from the specified
121mount point
122.Fa dir .
123.Pp
124The
125.Fa flags
126argument may have one of the following values:
127.Bl -tag -width  M_SYNCHRONOUS
128.It Dv MNT_NOFORCE
129The unmount should fail if any files are active on the file system.
130.It Dv MNT_FORCE
131The file system should be forcibly unmounted even if files are
132still active.
133Active special devices continue to work,
134but any further accesses to any other active files result in errors
135even if the file system is later remounted.
136.El
137.Sh RETURN VALUES
138The
139.Fn mount
140returns the value 0 if the mount was successful, otherwise -1 is returned
141and the variable
142.Va errno
143is set to indicate the error.
144.Pp
145.Nm Umount
146returns the value 0 if the umount succeeded; otherwise -1 is returned
147and the variable
148.Va errno
149is set to indicate the error.
150.Sh ERRORS
151.Fn Mount
152will fail when one of the following occurs:
153.Bl -tag -width [ENOTBLK]
154.It Bq Er EPERM
155The caller is not the super-user.
156.It Bq Er ENAMETOOLONG
157A component of a pathname exceeded 255 characters,
158or the entire length of a path name exceeded 1023 characters.
159.It Bq Er ELOOP
160Too many symbolic links were encountered in translating a pathname.
161.It Bq Er ENOENT
162A component of
163.Fa dir
164does not exist.
165.It Bq Er ENOTDIR
166A component of
167.Ar name
168is not a directory,
169or a path prefix of
170.Ar special
171is not a directory.
172.It Bq Er EINVAL
173A pathname contains a character with the high-order bit set.
174.It Bq Er EBUSY
175Another process currently holds a reference to
176.Fa dir .
177.It Bq Er EFAULT
178.Fa Dir
179points outside the process's allocated address space.
180.El
181.Pp
182The following errors can occur for a
183.Em ufs
184file system mount:
185.Bl -tag -width [ENOTBLK]
186.It Bq Er ENODEV
187A component of ufs_args
188.Ar fspec
189does not exist.
190.It Bq Er ENOTBLK
191.Ar Fspec
192is not a block device.
193.It Bq Er ENXIO
194The major device number of
195.Ar fspec
196is out of range (this indicates no device driver exists
197for the associated hardware).
198.It Bq Er EBUSY
199.Ar Fspec
200is already mounted.
201.It Bq Er EMFILE
202No space remains in the mount table.
203.It Bq Er EINVAL
204The super block for the file system had a bad magic
205number or an out of range block size.
206.It Bq Er ENOMEM
207Not enough memory was available to read the cylinder
208group information for the file system.
209.It Bq Er EIO
210An I/O error occurred while reading the super block or
211cylinder group information.
212.It Bq Er EFAULT
213.Ar Fspec
214points outside the process's allocated address space.
215.El
216.Pp
217The following errors can occur for a
218.Em nfs
219file system mount:
220.Bl -tag -width [ENOTBLK]
221.It Bq Er ETIMEDOUT
222.Em Nfs
223timed out trying to contact the server.
224.It Bq Er EFAULT
225Some part of the information described by nfs_args
226points outside the process's allocated address space.
227.El
228.Pp
229The following errors can occur for a
230.Em mfs
231file system mount:
232.Bl -tag -width [ENOTBLK]
233.It Bq Er EMFILE
234No space remains in the mount table.
235.It Bq Er EINVAL
236The super block for the file system had a bad magic
237number or an out of range block size.
238.It Bq Er ENOMEM
239Not enough memory was available to read the cylinder
240group information for the file system.
241.It Bq Er EIO
242An paging error occurred while reading the super block or
243cylinder group information.
244.It Bq Er EFAULT
245.Em Name
246points outside the process's allocated address space.
247.El
248.Pp
249.Em Umount
250may fail with one of the following errors:
251.Bl -tag -width [ENOTBLK]
252.It Bq Er EPERM
253The caller is not the super-user.
254.It Bq Er ENOTDIR
255A component of the path is not a directory.
256.It Bq Er EINVAL
257The pathname contains a character with the high-order bit set.
258.It Bq Er ENAMETOOLONG
259A component of a pathname exceeded 255 characters,
260or an entire path name exceeded 1023 characters.
261.It Bq Er ELOOP
262Too many symbolic links were encountered in translating the pathname.
263.It Bq Er EINVAL
264The requested directory is not in the mount table.
265.It Bq Er EBUSY
266A process is holding a reference to a file located
267on the file system.
268.It Bq Er EIO
269An I/O error occurred while writing cached file system information.
270.It Bq Er EFAULT
271.Fa Dir
272points outside the process's allocated address space.
273.El
274.Pp
275A
276.Em ufs
277or
278.Em mfs
279mount can also fail if the maximum number of filesystems are currently
280mounted.
281.Sh SEE ALSO
282.Xr mount 8 ,
283.Xr umount 8 ,
284.Xr mfs 8
285.Sh BUGS
286Some of the error codes need translation to more obvious messages.
287.Sh HISTORY
288.Fn Mount
289and
290.Fn umount
291function calls appeared in Version 6 AT&T UNIX.
292