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