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