Start development on 386BSD 0.0
[unix-history] / .ref-BSD-4_3_Net_2 / usr / src / lib / libc / sys / mount.2
CommitLineData
156f4461
KM
1.\" Copyright (c) 1980, 1989 The Regents of the University of California.
2.\" All rights reserved.
75f4d1ff 3.\"
af359dea
C
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.
156f4461 19.\"
af359dea
C
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.
75f4d1ff 31.\"
af359dea
C
32.\" @(#)mount.2 6.12 (Berkeley) 3/15/91
33.\"
34.Dd March 15, 1991
931b8415
CL
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
75f4d1ff 48The
931b8415
CL
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
156f4461 79The file system should be treated as read-only;
931b8415
CL
80Even the super-user may not write on it.
81.It Dv M_NOEXEC
156f4461 82Do not allow files to be executed from the file system.
931b8415 83.It Dv M_NOSUID
537ddbbc 84Do not honor setuid or setgid bits on files when executing them.
931b8415 85.It Dv M_NODEV
156f4461 86Do not interpret special files on the file system.
931b8415 87.It Dv M_SYNCHRONOUS
156f4461 88All I/O to the file system should be done synchronously.
931b8415
CL
89.El
90.Pp
91The flag
92.Dv M_UPDATE
93indicates that the mount command is being applied
f8865310
KM
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.
931b8415 100.Pp
156f4461 101The
931b8415 102.Fa type
156f4461
KM
103argument defines the type of the file system.
104The types of file systems known to the system are defined in
931b8415
CL
105.Aq Pa sys/mount.h .
106.Fa Data
156f4461
KM
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:
931b8415
CL
111.Pp
112.Dv MOUNT_UFS
619497d0 113.Bd -literal -offset indent -compact
156f4461 114struct ufs_args {
619497d0
CL
115 char *fspec; /* Block special file to mount */
116 int exflags; /* export related flags */
117 uid_t exroot; /* mapping for root uid */
156f4461 118};
931b8415
CL
119.Ed
120.Pp
121.Dv MOUNT_NFS
619497d0 122.Bd -literal -offset indent -compact
156f4461 123struct nfs_args {
619497d0
CL
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 */
156f4461 132};
931b8415
CL
133.Ed
134.Pp
135.Dv MOUNT_MFS
619497d0 136.Bd -literal -offset indent -compact
537ddbbc 137struct mfs_args {
619497d0
CL
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 */
537ddbbc 141};
931b8415
CL
142.Ed
143.Pp
156f4461 144The
931b8415
CL
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
156f4461 155The unmount should fail if any files are active on the file system.
931b8415 156.It Dv MNT_FORCE
156f4461
KM
157The file system should be forcibly unmounted even if files are
158still active.
f8a965b6
KM
159Active special devices continue to work,
160but any further accesses to any other active files result in errors
156f4461 161even if the file system is later remounted.
931b8415
CL
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
28e2febc 178will fail when one of the following occurs:
931b8415
CL
179.Bl -tag -width [ENOTBLK]
180.It Bq Er EPERM
156f4461 181The caller is not the super-user.
931b8415 182.It Bq Er ENAMETOOLONG
156f4461
KM
183A component of a pathname exceeded 255 characters,
184or the entire length of a path name exceeded 1023 characters.
931b8415 185.It Bq Er ELOOP
156f4461 186Too many symbolic links were encountered in translating a pathname.
931b8415
CL
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
156f4461 199A pathname contains a character with the high-order bit set.
931b8415 200.It Bq Er EBUSY
156f4461 201Another process currently holds a reference to
931b8415
CL
202.Fa dir .
203.It Bq Er EFAULT
204.Fa Dir
205points outside the process's allocated address space.
206.El
207.Pp
156f4461 208The following errors can occur for a
931b8415 209.Em ufs
156f4461 210file system mount:
931b8415
CL
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
28e2febc 218is not a block device.
931b8415 219.It Bq Er ENXIO
28e2febc 220The major device number of
931b8415 221.Ar fspec
28e2febc
KM
222is out of range (this indicates no device driver exists
223for the associated hardware).
931b8415
CL
224.It Bq Er EBUSY
225.Ar Fspec
226is already mounted.
227.It Bq Er EMFILE
156f4461 228No space remains in the mount table.
931b8415 229.It Bq Er EINVAL
28e2febc
KM
230The super block for the file system had a bad magic
231number or an out of range block size.
931b8415 232.It Bq Er ENOMEM
28e2febc
KM
233Not enough memory was available to read the cylinder
234group information for the file system.
931b8415 235.It Bq Er EIO
fd690c8b 236An I/O error occurred while reading the super block or
28e2febc 237cylinder group information.
931b8415
CL
238.It Bq Er EFAULT
239.Ar Fspec
240points outside the process's allocated address space.
241.El
242.Pp
156f4461 243The following errors can occur for a
931b8415 244.Em nfs
156f4461 245file system mount:
931b8415
CL
246.Bl -tag -width [ENOTBLK]
247.It Bq Er ETIMEDOUT
248.Em Nfs
156f4461 249timed out trying to contact the server.
931b8415 250.It Bq Er EFAULT
156f4461
KM
251Some part of the information described by nfs_args
252points outside the process's allocated address space.
931b8415
CL
253.El
254.Pp
537ddbbc 255The following errors can occur for a
931b8415 256.Em mfs
537ddbbc 257file system mount:
931b8415
CL
258.Bl -tag -width [ENOTBLK]
259.It Bq Er EMFILE
537ddbbc 260No space remains in the mount table.
931b8415 261.It Bq Er EINVAL
537ddbbc
KM
262The super block for the file system had a bad magic
263number or an out of range block size.
931b8415 264.It Bq Er ENOMEM
537ddbbc
KM
265Not enough memory was available to read the cylinder
266group information for the file system.
931b8415 267.It Bq Er EIO
537ddbbc
KM
268An paging error occurred while reading the super block or
269cylinder group information.
931b8415
CL
270.It Bq Er EFAULT
271.Em Name
272points outside the process's allocated address space.
273.El
274.Pp
619497d0 275.Nm Umount
28e2febc 276may fail with one of the following errors:
931b8415
CL
277.Bl -tag -width [ENOTBLK]
278.It Bq Er EPERM
156f4461 279The caller is not the super-user.
931b8415 280.It Bq Er ENOTDIR
156f4461 281A component of the path is not a directory.
931b8415 282.It Bq Er EINVAL
b5984ffe 283The pathname contains a character with the high-order bit set.
931b8415 284.It Bq Er ENAMETOOLONG
b5984ffe
KM
285A component of a pathname exceeded 255 characters,
286or an entire path name exceeded 1023 characters.
931b8415 287.It Bq Er ELOOP
b5984ffe 288Too many symbolic links were encountered in translating the pathname.
931b8415 289.It Bq Er EINVAL
156f4461 290The requested directory is not in the mount table.
931b8415 291.It Bq Er EBUSY
28e2febc
KM
292A process is holding a reference to a file located
293on the file system.
931b8415 294.It Bq Er EIO
156f4461 295An I/O error occurred while writing cached file system information.
931b8415
CL
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
b5984ffe 312Some of the error codes need translation to more obvious messages.
931b8415
CL
313.Sh HISTORY
314.Fn Mount
315and
316.Fn umount
317function calls appeared in Version 6 AT&T UNIX.