xref: /netbsd-src/lib/libc/sys/mount.2 (revision ae9172d6cd9432a6a1a56760d86b32c57a66c39c)
1.\" Copyright (c) 1980, 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     from: @(#)mount.2	6.12 (Berkeley) 3/15/91
33.\"	$Id: mount.2,v 1.7 1994/04/22 00:13:42 jtc Exp $
34.\"
35.Dd March 15, 1991
36.Dt MOUNT 2
37.Os BSD 4
38.Sh NAME
39.Nm mount ,
40.Nm unmount
41.Nd mount or dismount a filesystem
42.Sh SYNOPSIS
43.Fd #include <sys/mount.h>
44.Ft int
45.Fn mount "int type" "const char *dir" "int flags" "caddr_t data"
46.Ft int
47.Fn unmount "const char *dir" "int flags"
48.Sh DESCRIPTION
49The
50.Fn mount
51function grafts
52a filesystem object onto the system file tree
53at the point
54.Ar dir .
55The argument
56.Ar data
57describes the filesystem 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 filesystem
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 filesystem is unmounted.
73.Pp
74The following
75.Ar flags
76may be specified to
77suppress default semantics which affect filesystem access.
78.Bl -tag -width MNT_SYNCHRONOUS
79.It Dv MNT_RDONLY
80The file system should be treated as read-only;
81Even the super-user may not write on it.
82.It Dv MNT_NOEXEC
83Do not allow files to be executed from the file system.
84.It Dv MNT_NOSUID
85Do not honor setuid or setgid bits on files when executing them.
86.It Dv MNT_NODEV
87Do not interpret special files on the file system.
88.It Dv MNT_SYNCHRONOUS
89All I/O to the file system should be done synchronously.
90.El
91.Pp
92The flag
93.Dv MNT_UPDATE
94indicates that the mount command is being applied
95to an already mounted file system.
96This allows the mount flags to be changed without requiring
97that the file system be unmounted and remounted.
98Some file systems may not allow all flags to be changed.
99For example,
100most file systems will not allow a change from read-write to read-only.
101.Pp
102The
103.Fa type
104argument defines the type of the file system.
105The types of file systems known to the system are defined in
106.Aq Pa sys/mount.h .
107.Fa Data
108is a pointer to a structure that contains the type
109specific arguments to mount.
110The currently supported types of file systems and
111their type specific data are:
112.Pp
113.Dv MOUNT_UFS
114.Bd -literal -offset indent -compact
115struct ufs_args {
116      char	*fspec;  /* Block special file to mount */
117      int	exflags; /* export related flags */
118      uid_t	exroot;  /* mapping for root uid */
119};
120.Ed
121.Pp
122.Dv MOUNT_NFS
123.Bd -literal -offset indent -compact
124struct nfs_args {
125      struct sockaddr_in *addr; /* file server address */
126      nfsv2fh_t *fh;       /* File handle to be mounted */
127      int       flags;     /* flags */
128      int       wsize;     /* write size in bytes */
129      int       rsize;     /* read size in bytes */
130      int       timeo;     /* initial timeout 0.1 secs */
131      int       retrans;   /* times to retry send */
132      char      *hostname; /* server's name */
133};
134.Ed
135.Pp
136.Dv MOUNT_MFS
137.Bd -literal -offset indent -compact
138struct mfs_args {
139      char	*name;	/* name of backing process */
140      caddr_t	base;	/* base address of the file system */
141      u_long	size;	/* size of the file system */
142};
143.Ed
144.Pp
145The
146.Fn umount
147function call disassociates the filesystem from the specified
148mount point
149.Fa dir .
150.Pp
151The
152.Fa flags
153argument may have one of the following values:
154.Bl -tag -width  MNT_SYNCHRONOUS
155.It Dv MNT_NOFORCE
156The unmount should fail if any files are active on the file system.
157.It Dv MNT_FORCE
158The file system should be forcibly unmounted even if files are
159still active.
160Active special devices continue to work,
161but any further accesses to any other active files result in errors
162even if the file system is later remounted.
163.El
164.Sh RETURN VALUES
165The
166.Fn mount
167returns the value 0 if the mount was successful, otherwise -1 is returned
168and the variable
169.Va errno
170is set to indicate the error.
171.Pp
172.Nm Umount
173returns the value 0 if the umount succeeded; otherwise -1 is returned
174and the variable
175.Va errno
176is set to indicate the error.
177.Sh ERRORS
178.Fn Mount
179will fail when one of the following occurs:
180.Bl -tag -width Er
181.It Bq Er EPERM
182The caller is not the super-user.
183.It Bq Er ENAMETOOLONG
184A component of a pathname exceeded
185.Dv {NAME_MAX}
186characters, or an entire path name exceeded
187.Dv {PATH_MAX}
188characters.
189.It Bq Er ELOOP
190Too many symbolic links were encountered in translating a pathname.
191.It Bq Er ENOENT
192A component of
193.Fa dir
194does not exist.
195.It Bq Er ENOTDIR
196A component of
197.Ar name
198is not a directory,
199or a path prefix of
200.Ar special
201is not a directory.
202.It Bq Er EBUSY
203Another process currently holds a reference to
204.Fa dir .
205.It Bq Er EFAULT
206.Fa Dir
207points outside the process's allocated address space.
208.El
209.Pp
210The following errors can occur for a
211.Em ufs
212file system mount:
213.Bl -tag -width Er
214.It Bq Er ENODEV
215A component of ufs_args
216.Ar fspec
217does not exist.
218.It Bq Er ENOTBLK
219.Ar Fspec
220is not a block device.
221.It Bq Er ENXIO
222The major device number of
223.Ar fspec
224is out of range (this indicates no device driver exists
225for the associated hardware).
226.It Bq Er EBUSY
227.Ar Fspec
228is already mounted.
229.It Bq Er EMFILE
230No space remains in the mount table.
231.It Bq Er EINVAL
232The super block for the file system had a bad magic
233number or an out of range block size.
234.It Bq Er ENOMEM
235Not enough memory was available to read the cylinder
236group information for the file system.
237.It Bq Er EIO
238An I/O error occurred while reading the super block or
239cylinder group information.
240.It Bq Er EFAULT
241.Ar Fspec
242points outside the process's allocated address space.
243.El
244.Pp
245The following errors can occur for a
246.Em nfs
247file system mount:
248.Bl -tag -width Er
249.It Bq Er ETIMEDOUT
250.Em Nfs
251timed out trying to contact the server.
252.It Bq Er EFAULT
253Some part of the information described by nfs_args
254points outside the process's allocated address space.
255.El
256.Pp
257The following errors can occur for a
258.Em mfs
259file system mount:
260.Bl -tag -width Er
261.It Bq Er EMFILE
262No space remains in the mount table.
263.It Bq Er EINVAL
264The super block for the file system had a bad magic
265number or an out of range block size.
266.It Bq Er ENOMEM
267Not enough memory was available to read the cylinder
268group information for the file system.
269.It Bq Er EIO
270An paging error occurred while reading the super block or
271cylinder group information.
272.It Bq Er EFAULT
273.Em Name
274points outside the process's allocated address space.
275.El
276.Pp
277.Nm Umount
278may fail with one of the following errors:
279.Bl -tag -width Er
280.It Bq Er EPERM
281The caller is not the super-user.
282.It Bq Er ENOTDIR
283A component of the path is not a directory.
284.It Bq Er ENAMETOOLONG
285A component of a pathname exceeded
286.Dv {NAME_MAX}
287characters, or an entire path name exceeded
288.Dv {PATH_MAX}
289characters.
290.It Bq Er ELOOP
291Too many symbolic links were encountered in translating the pathname.
292.It Bq Er EINVAL
293The requested directory is not in the mount table.
294.It Bq Er EBUSY
295A process is holding a reference to a file located
296on the file system.
297.It Bq Er EIO
298An I/O error occurred while writing cached file system information.
299.It Bq Er EFAULT
300.Fa Dir
301points outside the process's allocated address space.
302.El
303.Pp
304A
305.Em ufs
306or
307.Em mfs
308mount can also fail if the maximum number of filesystems are currently
309mounted.
310.Sh SEE ALSO
311.Xr mount 8 ,
312.Xr umount 8 ,
313.Xr mfs 8
314.Sh BUGS
315Some of the error codes need translation to more obvious messages.
316.Sh HISTORY
317.Fn Mount
318and
319.Fn umount
320function calls appeared in
321.At v6 .
322