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