rev 5; copyright when created
[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.\"
156f4461
KM
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
16.\" @(#)mount.2 6.4 (Berkeley) %G%
75f4d1ff 17.\"
acbf19e9 18.TH MOUNT 2 ""
75f4d1ff
KM
19.UC 4
20.SH NAME
21mount, umount \- mount or remove file system
22.SH SYNOPSIS
23.nf
156f4461
KM
24#include <sys/mount.h>
25.sp
28e2febc 26.ft B
156f4461
KM
27mount(type, dir, flags, data)
28int type;
29char *dir;
30int flags;
31caddr_t data;
75f4d1ff 32.PP
28e2febc 33.ft B
156f4461
KM
34umount(dir, flags)
35char *dir;
36int flags;
75f4d1ff
KM
37.fi
38.SH DESCRIPTION
39.I Mount
156f4461
KM
40announces to the system that a file system has
41been mounted on the directory
42.IR dir ;
43following the mount, references to directory
44.I dir
75f4d1ff 45will refer to
156f4461
KM
46the root directory on the newly mounted file system.
47.I Dir
48is a pointer to a null-terminated string
49containing the appropriate path name
50which must be a directory that already exists.
51Its old contents are inaccessible while the
52file system is mounted.
75f4d1ff
KM
53.PP
54The
156f4461
KM
55.I flag
56argument determines whether certain semantics should be
57suppressed when accessing the file system:
58.IP M_RDONLY 14
59The file system should be treated as read-only;
60no writing is allowed (even by the super-user).
75f4d1ff
KM
61Physically write-protected and magnetic
62tape file systems must be mounted read-only or
63errors will occur when access times are updated,
64whether or not any
65explicit write is attempted.
156f4461
KM
66.IP M_NOEXEC 14
67Do not allow files to be executed from the file system.
68.IP M_NOSUID 14
69Do not honor setuid bits on files when executing them.
70.IP M_NODEV 14
71Do not interpret special files on the file system.
72.IP M_SYNCHRONOUS 14
73All I/O to the file system should be done synchronously.
74.PP
75The
76.I type
77argument defines the type of the file system.
78The types of file systems known to the system are defined in
79.I mount.h .
80.I Data
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:
85.IP MOUNT_UFS 6
86.nf
87.ta \w'struct 'u +\w'nfsv2fh_t 'u +\w'sockaddr_in *addr 'u
88struct ufs_args {
89 char *fspec; /* Block special file to mount */
90};
91.fi
92.sp
93.IP MOUNT_NFS 6
94.nf
95struct nfs_args {
96 struct sockaddr_in *addr; /* file server address */
97 nfsv2fh_t *fh; /* File handle to be mounted */
98 int flags; /* flags */
99 int wsize; /* write size in bytes */
100 int rsize; /* read size in bytes */
101 int timeo; /* initial timeout in 0.1 secs */
102 int retrans; /* times to retry send */
103 char *hostname; /* server's name */
104};
105.fi
75f4d1ff
KM
106.PP
107.I Umount
156f4461
KM
108announces to the system that the file system mounted at
109.I dir
110is no longer to contain that file system.
111The associated directory reverts to its ordinary interpretation.
112.PP
113The
114.I flags
115argument may have the following values:
116.IP MNT_NOFORCE 12
117The unmount should fail if any files are active on the file system.
118.IP MNT_FORCE 12
119The file system should be forcibly unmounted even if files are
120still active.
121Any further accesses to the active files results in errors
122even if the file system is later remounted.
123This flag is not currently supported on any file system type.
28e2febc 124.SH "RETURN VALUE
75f4d1ff 125.I Mount
156f4461
KM
126returns 0 if the action occurred, \-1 if an error occurred.
127The mount can fail if
128.I dir
129does not exist or is not a directory.
130For a
131.I ufs
132file system, the mount can fail if the special device
133specified in the ufs_args structure is
134inaccessible, is not an appropriate file, or is already mounted.
135A
136.I ufs
137mount can also fail if there are already too many
75f4d1ff
KM
138file systems mounted.
139.PP
140.I Umount
156f4461
KM
141returns 0 if the action occurred; \-1 if an error occurred.
142The unmount will fail
143if there are active files in the mounted file system.
28e2febc
KM
144.SH ERRORS
145.I Mount
146will fail when one of the following occurs:
147.TP 15
156f4461
KM
148[EPERM]
149The caller is not the super-user.
150.TP 15
b5984ffe 151[ENAMETOOLONG]
156f4461
KM
152A component of a pathname exceeded 255 characters,
153or the entire length of a path name exceeded 1023 characters.
b5984ffe
KM
154.TP 15
155[ELOOP]
156f4461 156Too many symbolic links were encountered in translating a pathname.
28e2febc 157.TP 15
b5984ffe 158[ENOENT]
156f4461
KM
159A component of \fIdir\fP does not exist.
160.TP 15
161[ENOTDIR]
162A component of \fIname\fP is not a directory,
163or a path prefix of \fIspecial\fP is not a directory.
164.TP 15
165[EINVAL]
166A pathname contains a character with the high-order bit set.
167.TP 15
168[EBUSY]
169Another process currently holds a reference to
170.IR dir .
171.TP 15
172[EFAULT]
173\fIDir\fP points outside the process's allocated address space.
174.PP
175The following errors can occur for a
176.I ufs
177file system mount:
b5984ffe
KM
178.TP 15
179[ENODEV]
156f4461 180A component of ufs_args \fIfspec\fP does not exist.
28e2febc
KM
181.TP 15
182[ENOTBLK]
156f4461 183.I Fspec
28e2febc
KM
184is not a block device.
185.TP 15
186[ENXIO]
187The major device number of
156f4461 188.I fspec
28e2febc
KM
189is out of range (this indicates no device driver exists
190for the associated hardware).
191.TP 15
156f4461
KM
192[EBUSY]
193\fIFspec\fP is already mounted.
28e2febc 194.TP 15
156f4461
KM
195[EMFILE]
196No space remains in the mount table.
28e2febc 197.TP 15
b5984ffe 198[EINVAL]
28e2febc
KM
199The super block for the file system had a bad magic
200number or an out of range block size.
201.TP 15
b5984ffe 202[ENOMEM]
28e2febc
KM
203Not enough memory was available to read the cylinder
204group information for the file system.
205.TP 15
b5984ffe 206[EIO]
fd690c8b 207An I/O error occurred while reading the super block or
28e2febc 208cylinder group information.
fd690c8b
KM
209.TP 15
210[EFAULT]
156f4461
KM
211\fIFspec\fP points outside the process's allocated address space.
212.PP
213The following errors can occur for a
214.I nfs
215file system mount:
216.TP 15
217[ETIMEDOUT]
218.I Nfs
219timed out trying to contact the server.
220.TP 15
221[EFAULT]
222Some part of the information described by nfs_args
223points outside the process's allocated address space.
75f4d1ff 224.PP
28e2febc
KM
225.I Umount
226may fail with one of the following errors:
227.TP 15
156f4461
KM
228[EPERM]
229The caller is not the super-user.
230.TP 15
b5984ffe 231[ENOTDIR]
156f4461 232A component of the path is not a directory.
b5984ffe
KM
233.TP 15
234[EINVAL]
235The pathname contains a character with the high-order bit set.
236.TP 15
237[ENAMETOOLONG]
238A component of a pathname exceeded 255 characters,
239or an entire path name exceeded 1023 characters.
240.TP 15
241[ELOOP]
242Too many symbolic links were encountered in translating the pathname.
243.TP 15
28e2febc 244[EINVAL]
156f4461 245The requested directory is not in the mount table.
28e2febc
KM
246.TP 15
247[EBUSY]
248A process is holding a reference to a file located
249on the file system.
fd690c8b
KM
250.TP 15
251[EIO]
156f4461 252An I/O error occurred while writing cached file system information.
fd690c8b
KM
253.TP 15
254[EFAULT]
156f4461 255\fIDir\fP points outside the process's allocated address space.
28e2febc
KM
256.SH "SEE ALSO"
257mount(8), umount(8)
258.SH BUGS
b5984ffe 259Some of the error codes need translation to more obvious messages.