]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man2/mount.2
xnu-3248.60.10.tar.gz
[apple/xnu.git] / bsd / man / man2 / mount.2
CommitLineData
9bccf70c
A
1.\" $OpenBSD: mount.2,v 1.6 1997/03/09 19:41:16 millert Exp $
2.\" $NetBSD: mount.2,v 1.12 1996/02/29 23:47:48 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1989, 1993
5.\" The Regents of the University of California. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)mount.2 8.2 (Berkeley) 12/11/93
36.\"
37.Dd December 11, 1993
38.Dt MOUNT 2
39.Os BSD 4
40.Sh NAME
41.Nm mount ,
42.Nm unmount
43.Nd mount or dismount a filesystem
44.Sh SYNOPSIS
45.Fd #include <sys/param.h>
46.Fd #include <sys/mount.h>
47.Ft int
48.Fn mount "const char *type" "const char *dir" "int flags" "void *data"
49.Ft int
50.Fn unmount "const char *dir" "int flags"
51.Sh DESCRIPTION
52The
53.Fn mount
54function grafts
55a filesystem object onto the system file tree
56at the point
57.Ar dir .
58The argument
59.Ar data
60describes the filesystem object to be mounted.
61The argument
62.Ar type
63tells the kernel how to interpret
64.Ar data
65(See
66.Ar type
67below).
68The contents of the filesystem
69become available through the new mount point
70.Ar dir .
71Any files in
72.Ar dir
73at the time
74of a successful mount are swept under the carpet so to speak, and
75are unavailable until the filesystem is unmounted.
76.Pp
77The following
78.Ar flags
79may be specified to
80suppress default semantics which affect filesystem access.
81.Bl -tag -width MNT_SYNCHRONOUS
82.It Dv MNT_RDONLY
83The filesystem should be treated as read-only;
84Even the super-user may not write on it.
9bccf70c
A
85.It Dv MNT_NOEXEC
86Do not allow files to be executed from the filesystem.
87.It Dv MNT_NOSUID
88Do not honor setuid or setgid bits on files when executing them.
89.It Dv MNT_NODEV
90Do not interpret special files on the filesystem.
91.It Dv MNT_UNION
92Union with underlying filesystem instead of obscuring it.
93.It Dv MNT_SYNCHRONOUS
94All I/O to the filesystem should be done synchronously.
3e170ce0
A
95.It Dv MNT_CPROTECT
96Enable data protection on the filesystem if the filesystem is configured for it.
9bccf70c
A
97.El
98.Pp
99The flag
100.Dv MNT_UPDATE
101indicates that the mount command is being applied
102to an already mounted filesystem.
103This allows the mount flags to be changed without requiring
104that the filesystem be unmounted and remounted.
105Some filesystems may not allow all flags to be changed.
106For example,
107most filesystems will not allow a change from read-write to read-only.
108.Pp
55e303ae
A
109The flag
110.Dv MNT_RELOAD
111causes the vfs subsystem to update its data structures pertaining to
112the specified already mounted filesystem.
113.Pp
9bccf70c
A
114The
115.Fa type
116argument defines the type of the filesystem.
55e303ae 117.Pp
9bccf70c
A
118.Fa Data
119is a pointer to a structure that contains the type
120specific arguments to mount.
55e303ae
A
121The format for these argument structures is described in the
122manual page for each filesystem.
9bccf70c
A
123.Pp
124The
3e170ce0 125.Fn unmount
9bccf70c
A
126function call disassociates the filesystem from the specified
127mount point
128.Fa dir .
129.Pp
130The
131.Fa flags
132argument may specify
133.Dv MNT_FORCE
134to specify that the filesystem should be forcibly unmounted even if files are
135still active.
136Active special devices continue to work,
137but any further accesses to any other active files result in errors
138even if the filesystem is later remounted.
139.Sh RETURN VALUES
140The
141.Fn mount
142returns the value 0 if the mount was successful, otherwise -1 is returned
143and the variable
144.Va errno
145is set to indicate the error.
146.Pp
3e170ce0
A
147.Nm unmount
148returns the value 0 if the unmount succeeded; otherwise -1 is returned
9bccf70c
A
149and the variable
150.Va errno
151is set to indicate the error.
152.Sh ERRORS
153.Fn Mount
154will fail when one of the following occurs:
155.Bl -tag -width [ENAMETOOLONG]
156.It Bq Er EPERM
55e303ae
A
157The caller is not the super-user, and the device-node and the mountpoint
158do not have adequate ownership and permissions.
9bccf70c
A
159.It Bq Er ENAMETOOLONG
160A component of a pathname exceeded
161.Dv {NAME_MAX}
162characters, or an entire path name exceeded
163.Dv {PATH_MAX}
164characters.
165.It Bq Er ELOOP
166Too many symbolic links were encountered in translating a pathname.
167.It Bq Er ENOENT
168A component of
169.Fa dir
170does not exist.
171.It Bq Er ENOTDIR
172A component of
173.Ar name
174is not a directory,
175or a path prefix of
176.Ar special
177is not a directory.
178.It Bq Er EINVAL
179A pathname contains a character with the high-order bit set.
180.It Bq Er EBUSY
181Another process currently holds a reference to
182.Fa dir .
183.It Bq Er EFAULT
184.Fa Dir
185points outside the process's allocated address space.
186.El
187.Pp
3e170ce0 188.Nm unmount
9bccf70c
A
189may fail with one of the following errors:
190.Bl -tag -width [ENAMETOOLONG]
191.It Bq Er EPERM
55e303ae
A
192The caller is not the super-user, and the
193.Nm mount()
194was not done by the user.
9bccf70c
A
195.It Bq Er ENOTDIR
196A component of the path is not a directory.
197.It Bq Er EINVAL
198The pathname contains a character with the high-order bit set.
199.It Bq Er ENAMETOOLONG
200A component of a pathname exceeded
201.Dv {NAME_MAX}
202characters, or an entire path name exceeded
203.Dv {PATH_MAX}
204characters.
205.It Bq Er ELOOP
206Too many symbolic links were encountered in translating the pathname.
207.It Bq Er EINVAL
208The requested directory is not in the mount table.
209.It Bq Er EBUSY
210A process is holding a reference to a file located
211on the filesystem.
212.It Bq Er EIO
213An I/O error occurred while writing cached filesystem information.
214.It Bq Er EFAULT
215.Fa Dir
216points outside the process's allocated address space.
217.El
9bccf70c
A
218.Sh SEE ALSO
219.Xr mount 8 ,
3e170ce0 220.Xr unmount 8
9bccf70c
A
221.Sh BUGS
222Some of the error codes need translation to more obvious messages.
223.Sh HISTORY
224.Fn Mount
225and
3e170ce0 226.Fn unmount
9bccf70c
A
227function calls appeared in
228.At v6 .