man page macro and text revisions (-mdoc version 3)
[unix-history] / 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.\"
91cff1e1 4.\" %sccs.include.redist.man%
156f4461 5.\"
931b8415 6.\" @(#)mount.2 6.11 (Berkeley) %G%
75f4d1ff 7.\"
931b8415
CL
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
75f4d1ff 22The
931b8415
CL
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
156f4461 53The file system should be treated as read-only;
931b8415
CL
54Even the super-user may not write on it.
55.It Dv M_NOEXEC
156f4461 56Do not allow files to be executed from the file system.
931b8415 57.It Dv M_NOSUID
537ddbbc 58Do not honor setuid or setgid bits on files when executing them.
931b8415 59.It Dv M_NODEV
156f4461 60Do not interpret special files on the file system.
931b8415 61.It Dv M_SYNCHRONOUS
156f4461 62All I/O to the file system should be done synchronously.
931b8415
CL
63.El
64.Pp
65The flag
66.Dv M_UPDATE
67indicates that the mount command is being applied
f8865310
KM
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.
931b8415 74.Pp
156f4461 75The
931b8415 76.Fa type
156f4461
KM
77argument defines the type of the file system.
78The types of file systems known to the system are defined in
931b8415
CL
79.Aq Pa sys/mount.h .
80.Fa Data
156f4461
KM
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:
931b8415
CL
85.Pp
86.Dv MOUNT_UFS
87.Bd -literal -compact -offset indent
156f4461
KM
88struct ufs_args {
89 char *fspec; /* Block special file to mount */
1b683cb2
KM
90 int exflags; /* export related flags */
91 uid_t exroot; /* mapping for root uid */
156f4461 92};
931b8415
CL
93.Ed
94.Pp
95.Dv MOUNT_NFS
96.Bd -literal -compact -offset indent
156f4461
KM
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};
931b8415
CL
107.Ed
108.Pp
109.Dv MOUNT_MFS
110.Bd -literal -compact -offset indent
537ddbbc
KM
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};
931b8415
CL
116.Ed
117.Pp
156f4461 118The
931b8415
CL
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
156f4461 129The unmount should fail if any files are active on the file system.
931b8415 130.It Dv MNT_FORCE
156f4461
KM
131The file system should be forcibly unmounted even if files are
132still active.
f8a965b6
KM
133Active special devices continue to work,
134but any further accesses to any other active files result in errors
156f4461 135even if the file system is later remounted.
931b8415
CL
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
28e2febc 152will fail when one of the following occurs:
931b8415
CL
153.Bl -tag -width [ENOTBLK]
154.It Bq Er EPERM
156f4461 155The caller is not the super-user.
931b8415 156.It Bq Er ENAMETOOLONG
156f4461
KM
157A component of a pathname exceeded 255 characters,
158or the entire length of a path name exceeded 1023 characters.
931b8415 159.It Bq Er ELOOP
156f4461 160Too many symbolic links were encountered in translating a pathname.
931b8415
CL
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
156f4461 173A pathname contains a character with the high-order bit set.
931b8415 174.It Bq Er EBUSY
156f4461 175Another process currently holds a reference to
931b8415
CL
176.Fa dir .
177.It Bq Er EFAULT
178.Fa Dir
179points outside the process's allocated address space.
180.El
181.Pp
156f4461 182The following errors can occur for a
931b8415 183.Em ufs
156f4461 184file system mount:
931b8415
CL
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
28e2febc 192is not a block device.
931b8415 193.It Bq Er ENXIO
28e2febc 194The major device number of
931b8415 195.Ar fspec
28e2febc
KM
196is out of range (this indicates no device driver exists
197for the associated hardware).
931b8415
CL
198.It Bq Er EBUSY
199.Ar Fspec
200is already mounted.
201.It Bq Er EMFILE
156f4461 202No space remains in the mount table.
931b8415 203.It Bq Er EINVAL
28e2febc
KM
204The super block for the file system had a bad magic
205number or an out of range block size.
931b8415 206.It Bq Er ENOMEM
28e2febc
KM
207Not enough memory was available to read the cylinder
208group information for the file system.
931b8415 209.It Bq Er EIO
fd690c8b 210An I/O error occurred while reading the super block or
28e2febc 211cylinder group information.
931b8415
CL
212.It Bq Er EFAULT
213.Ar Fspec
214points outside the process's allocated address space.
215.El
216.Pp
156f4461 217The following errors can occur for a
931b8415 218.Em nfs
156f4461 219file system mount:
931b8415
CL
220.Bl -tag -width [ENOTBLK]
221.It Bq Er ETIMEDOUT
222.Em Nfs
156f4461 223timed out trying to contact the server.
931b8415 224.It Bq Er EFAULT
156f4461
KM
225Some part of the information described by nfs_args
226points outside the process's allocated address space.
931b8415
CL
227.El
228.Pp
537ddbbc 229The following errors can occur for a
931b8415 230.Em mfs
537ddbbc 231file system mount:
931b8415
CL
232.Bl -tag -width [ENOTBLK]
233.It Bq Er EMFILE
537ddbbc 234No space remains in the mount table.
931b8415 235.It Bq Er EINVAL
537ddbbc
KM
236The super block for the file system had a bad magic
237number or an out of range block size.
931b8415 238.It Bq Er ENOMEM
537ddbbc
KM
239Not enough memory was available to read the cylinder
240group information for the file system.
931b8415 241.It Bq Er EIO
537ddbbc
KM
242An paging error occurred while reading the super block or
243cylinder group information.
931b8415
CL
244.It Bq Er EFAULT
245.Em Name
246points outside the process's allocated address space.
247.El
248.Pp
249.Em Umount
28e2febc 250may fail with one of the following errors:
931b8415
CL
251.Bl -tag -width [ENOTBLK]
252.It Bq Er EPERM
156f4461 253The caller is not the super-user.
931b8415 254.It Bq Er ENOTDIR
156f4461 255A component of the path is not a directory.
931b8415 256.It Bq Er EINVAL
b5984ffe 257The pathname contains a character with the high-order bit set.
931b8415 258.It Bq Er ENAMETOOLONG
b5984ffe
KM
259A component of a pathname exceeded 255 characters,
260or an entire path name exceeded 1023 characters.
931b8415 261.It Bq Er ELOOP
b5984ffe 262Too many symbolic links were encountered in translating the pathname.
931b8415 263.It Bq Er EINVAL
156f4461 264The requested directory is not in the mount table.
931b8415 265.It Bq Er EBUSY
28e2febc
KM
266A process is holding a reference to a file located
267on the file system.
931b8415 268.It Bq Er EIO
156f4461 269An I/O error occurred while writing cached file system information.
931b8415
CL
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
b5984ffe 286Some of the error codes need translation to more obvious messages.
931b8415
CL
287.Sh HISTORY
288.Fn Mount
289and
290.Fn umount
291function calls appeared in Version 6 AT&T UNIX.