get rid of unneeded header files
[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.\"
eb9b2c86 16.\" @(#)mount.2 6.8 (Berkeley) %G%
75f4d1ff 17.\"
acbf19e9 18.TH MOUNT 2 ""
75f4d1ff
KM
19.UC 4
20.SH NAME
eb9b2c86 21mount, unmount \- mount or remove file system
75f4d1ff
KM
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
eb9b2c86 34unmount(dir, flags)
156f4461
KM
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
537ddbbc 69Do not honor setuid or setgid bits on files when executing them.
156f4461
KM
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
f8865310
KM
75The flag M_UPDATE indicates that the mount command is being applied
76to an already mounted file system.
77This allows the mount flags to be changed without requiring
78that the file system be unmounted and remounted.
79Some file systems may not allow all flags to be changed.
80For example,
81most file systems will not allow a change from read-write to read-only.
82.PP
156f4461
KM
83The
84.I type
85argument defines the type of the file system.
86The types of file systems known to the system are defined in
537ddbbc 87.IR mount.h .
156f4461
KM
88.I Data
89is a pointer to a structure that contains the type
90specific arguments to mount.
91The currently supported types of file systems and
92their type specific data are:
93.IP MOUNT_UFS 6
94.nf
95.ta \w'struct 'u +\w'nfsv2fh_t 'u +\w'sockaddr_in *addr 'u
96struct ufs_args {
97 char *fspec; /* Block special file to mount */
98};
99.fi
100.sp
101.IP MOUNT_NFS 6
102.nf
103struct nfs_args {
104 struct sockaddr_in *addr; /* file server address */
105 nfsv2fh_t *fh; /* File handle to be mounted */
106 int flags; /* flags */
107 int wsize; /* write size in bytes */
108 int rsize; /* read size in bytes */
109 int timeo; /* initial timeout in 0.1 secs */
110 int retrans; /* times to retry send */
111 char *hostname; /* server's name */
112};
113.fi
537ddbbc
KM
114.IP MOUNT_MFS 6
115.nf
116struct mfs_args {
117 char *name; /* name of backing process */
118 caddr_t base; /* base address of the file system */
119 u_long size; /* size of the file system */
120};
121.fi
122.sp
75f4d1ff
KM
123.PP
124.I Umount
156f4461
KM
125announces to the system that the file system mounted at
126.I dir
127is no longer to contain that file system.
128The associated directory reverts to its ordinary interpretation.
129.PP
130The
131.I flags
132argument may have the following values:
133.IP MNT_NOFORCE 12
134The unmount should fail if any files are active on the file system.
135.IP MNT_FORCE 12
136The file system should be forcibly unmounted even if files are
137still active.
f8a965b6
KM
138Active special devices continue to work,
139but any further accesses to any other active files result in errors
156f4461 140even if the file system is later remounted.
28e2febc 141.SH "RETURN VALUE
75f4d1ff 142.I Mount
156f4461
KM
143returns 0 if the action occurred, \-1 if an error occurred.
144The mount can fail if
145.I dir
146does not exist or is not a directory.
147For a
148.I ufs
149file system, the mount can fail if the special device
150specified in the ufs_args structure is
151inaccessible, is not an appropriate file, or is already mounted.
152A
153.I ufs
537ddbbc
KM
154or
155.I mfs
156f4461 156mount can also fail if there are already too many
75f4d1ff
KM
157file systems mounted.
158.PP
159.I Umount
156f4461
KM
160returns 0 if the action occurred; \-1 if an error occurred.
161The unmount will fail
162if there are active files in the mounted file system.
28e2febc
KM
163.SH ERRORS
164.I Mount
165will fail when one of the following occurs:
166.TP 15
156f4461
KM
167[EPERM]
168The caller is not the super-user.
169.TP 15
b5984ffe 170[ENAMETOOLONG]
156f4461
KM
171A component of a pathname exceeded 255 characters,
172or the entire length of a path name exceeded 1023 characters.
b5984ffe
KM
173.TP 15
174[ELOOP]
156f4461 175Too many symbolic links were encountered in translating a pathname.
28e2febc 176.TP 15
b5984ffe 177[ENOENT]
156f4461
KM
178A component of \fIdir\fP does not exist.
179.TP 15
180[ENOTDIR]
181A component of \fIname\fP is not a directory,
182or a path prefix of \fIspecial\fP is not a directory.
183.TP 15
184[EINVAL]
185A pathname contains a character with the high-order bit set.
186.TP 15
187[EBUSY]
188Another process currently holds a reference to
189.IR dir .
190.TP 15
191[EFAULT]
192\fIDir\fP points outside the process's allocated address space.
193.PP
194The following errors can occur for a
195.I ufs
196file system mount:
b5984ffe
KM
197.TP 15
198[ENODEV]
156f4461 199A component of ufs_args \fIfspec\fP does not exist.
28e2febc
KM
200.TP 15
201[ENOTBLK]
156f4461 202.I Fspec
28e2febc
KM
203is not a block device.
204.TP 15
205[ENXIO]
206The major device number of
156f4461 207.I fspec
28e2febc
KM
208is out of range (this indicates no device driver exists
209for the associated hardware).
210.TP 15
156f4461
KM
211[EBUSY]
212\fIFspec\fP is already mounted.
28e2febc 213.TP 15
156f4461
KM
214[EMFILE]
215No space remains in the mount table.
28e2febc 216.TP 15
b5984ffe 217[EINVAL]
28e2febc
KM
218The super block for the file system had a bad magic
219number or an out of range block size.
220.TP 15
b5984ffe 221[ENOMEM]
28e2febc
KM
222Not enough memory was available to read the cylinder
223group information for the file system.
224.TP 15
b5984ffe 225[EIO]
fd690c8b 226An I/O error occurred while reading the super block or
28e2febc 227cylinder group information.
fd690c8b
KM
228.TP 15
229[EFAULT]
156f4461
KM
230\fIFspec\fP points outside the process's allocated address space.
231.PP
232The following errors can occur for a
233.I nfs
234file system mount:
235.TP 15
236[ETIMEDOUT]
237.I Nfs
238timed out trying to contact the server.
239.TP 15
240[EFAULT]
241Some part of the information described by nfs_args
242points outside the process's allocated address space.
75f4d1ff 243.PP
537ddbbc
KM
244The following errors can occur for a
245.I mfs
246file system mount:
247.TP 15
248[EMFILE]
249No space remains in the mount table.
250.TP 15
251[EINVAL]
252The super block for the file system had a bad magic
253number or an out of range block size.
254.TP 15
255[ENOMEM]
256Not enough memory was available to read the cylinder
257group information for the file system.
258.TP 15
259[EIO]
260An paging error occurred while reading the super block or
261cylinder group information.
262.TP 15
263[EFAULT]
264\fIName\fP points outside the process's allocated address space.
265.PP
28e2febc
KM
266.I Umount
267may fail with one of the following errors:
268.TP 15
156f4461
KM
269[EPERM]
270The caller is not the super-user.
271.TP 15
b5984ffe 272[ENOTDIR]
156f4461 273A component of the path is not a directory.
b5984ffe
KM
274.TP 15
275[EINVAL]
276The pathname contains a character with the high-order bit set.
277.TP 15
278[ENAMETOOLONG]
279A component of a pathname exceeded 255 characters,
280or an entire path name exceeded 1023 characters.
281.TP 15
282[ELOOP]
283Too many symbolic links were encountered in translating the pathname.
284.TP 15
28e2febc 285[EINVAL]
156f4461 286The requested directory is not in the mount table.
28e2febc
KM
287.TP 15
288[EBUSY]
289A process is holding a reference to a file located
290on the file system.
fd690c8b
KM
291.TP 15
292[EIO]
156f4461 293An I/O error occurred while writing cached file system information.
fd690c8b
KM
294.TP 15
295[EFAULT]
156f4461 296\fIDir\fP points outside the process's allocated address space.
28e2febc 297.SH "SEE ALSO"
537ddbbc 298mount(8), umount(8), mfs(8)
28e2febc 299.SH BUGS
b5984ffe 300Some of the error codes need translation to more obvious messages.