]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man2/mount.2
xnu-7195.101.1.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 ,
5ba3f43e 42.Nm fmount,
9bccf70c
A
43.Nm unmount
44.Nd mount or dismount a filesystem
45.Sh SYNOPSIS
46.Fd #include <sys/param.h>
47.Fd #include <sys/mount.h>
48.Ft int
49.Fn mount "const char *type" "const char *dir" "int flags" "void *data"
50.Ft int
5ba3f43e
A
51.Fn fmount "const char *type" "int fd" "int flags" "void *data"
52.Ft int
9bccf70c
A
53.Fn unmount "const char *dir" "int flags"
54.Sh DESCRIPTION
55The
56.Fn mount
57function grafts
58a filesystem object onto the system file tree
59at the point
60.Ar dir .
61The argument
62.Ar data
63describes the filesystem object to be mounted.
64The argument
65.Ar type
66tells the kernel how to interpret
67.Ar data
68(See
69.Ar type
70below).
71The contents of the filesystem
72become available through the new mount point
73.Ar dir .
74Any files in
75.Ar dir
76at the time
77of a successful mount are swept under the carpet so to speak, and
78are unavailable until the filesystem is unmounted.
79.Pp
80The following
81.Ar flags
82may be specified to
83suppress default semantics which affect filesystem access.
84.Bl -tag -width MNT_SYNCHRONOUS
85.It Dv MNT_RDONLY
86The filesystem should be treated as read-only;
87Even the super-user may not write on it.
9bccf70c
A
88.It Dv MNT_NOEXEC
89Do not allow files to be executed from the filesystem.
90.It Dv MNT_NOSUID
91Do not honor setuid or setgid bits on files when executing them.
92.It Dv MNT_NODEV
93Do not interpret special files on the filesystem.
94.It Dv MNT_UNION
95Union with underlying filesystem instead of obscuring it.
96.It Dv MNT_SYNCHRONOUS
97All I/O to the filesystem should be done synchronously.
3e170ce0
A
98.It Dv MNT_CPROTECT
99Enable data protection on the filesystem if the filesystem is configured for it.
9bccf70c
A
100.El
101.Pp
102The flag
103.Dv MNT_UPDATE
104indicates that the mount command is being applied
105to an already mounted filesystem.
106This allows the mount flags to be changed without requiring
107that the filesystem be unmounted and remounted.
108Some filesystems may not allow all flags to be changed.
109For example,
110most filesystems will not allow a change from read-write to read-only.
111.Pp
55e303ae
A
112The flag
113.Dv MNT_RELOAD
114causes the vfs subsystem to update its data structures pertaining to
115the specified already mounted filesystem.
116.Pp
9bccf70c
A
117The
118.Fa type
119argument defines the type of the filesystem.
55e303ae 120.Pp
9bccf70c
A
121.Fa Data
122is a pointer to a structure that contains the type
123specific arguments to mount.
55e303ae
A
124The format for these argument structures is described in the
125manual page for each filesystem.
9bccf70c
A
126.Pp
127The
5ba3f43e
A
128.Fn fmount
129function call is equivalent to the
130.Fn mount
131function call, except in the use of the second argument.
132It takes an open file descriptor representing mount point
133instead of the string literal containing full path to the mount
134point in the filesystem hierarchy.
135.Pp
136The
3e170ce0 137.Fn unmount
9bccf70c
A
138function call disassociates the filesystem from the specified
139mount point
140.Fa dir .
141.Pp
142The
143.Fa flags
144argument may specify
145.Dv MNT_FORCE
146to specify that the filesystem should be forcibly unmounted even if files are
147still active.
148Active special devices continue to work,
149but any further accesses to any other active files result in errors
150even if the filesystem is later remounted.
151.Sh RETURN VALUES
152The
153.Fn mount
5ba3f43e
A
154and
155.Fn fmount
156return the value 0 if the mount was successful, otherwise -1 is returned
9bccf70c
A
157and the variable
158.Va errno
159is set to indicate the error.
160.Pp
3e170ce0
A
161.Nm unmount
162returns the value 0 if the unmount succeeded; otherwise -1 is returned
9bccf70c
A
163and the variable
164.Va errno
165is set to indicate the error.
166.Sh ERRORS
39037602 167.Fn mount
5ba3f43e
A
168and
169.Fn fmount
9bccf70c
A
170will fail when one of the following occurs:
171.Bl -tag -width [ENAMETOOLONG]
172.It Bq Er EPERM
55e303ae
A
173The caller is not the super-user, and the device-node and the mountpoint
174do not have adequate ownership and permissions.
9bccf70c
A
175.It Bq Er ENAMETOOLONG
176A component of a pathname exceeded
177.Dv {NAME_MAX}
178characters, or an entire path name exceeded
179.Dv {PATH_MAX}
180characters.
181.It Bq Er ELOOP
182Too many symbolic links were encountered in translating a pathname.
183.It Bq Er ENOENT
184A component of
185.Fa dir
186does not exist.
187.It Bq Er ENOTDIR
188A component of
189.Ar name
190is not a directory,
191or a path prefix of
192.Ar special
193is not a directory.
194.It Bq Er EINVAL
195A pathname contains a character with the high-order bit set.
196.It Bq Er EBUSY
197Another process currently holds a reference to
198.Fa dir .
199.It Bq Er EFAULT
200.Fa Dir
201points outside the process's allocated address space.
202.El
203.Pp
3e170ce0 204.Nm unmount
9bccf70c
A
205may fail with one of the following errors:
206.Bl -tag -width [ENAMETOOLONG]
207.It Bq Er EPERM
55e303ae
A
208The caller is not the super-user, and the
209.Nm mount()
210was not done by the user.
c3c9b80d
A
211.It Bq Er EPERM
212A system policy denied the operation.
9bccf70c
A
213.It Bq Er ENOTDIR
214A component of the path is not a directory.
215.It Bq Er EINVAL
216The pathname contains a character with the high-order bit set.
217.It Bq Er ENAMETOOLONG
218A component of a pathname exceeded
219.Dv {NAME_MAX}
220characters, or an entire path name exceeded
221.Dv {PATH_MAX}
222characters.
223.It Bq Er ELOOP
224Too many symbolic links were encountered in translating the pathname.
225.It Bq Er EINVAL
226The requested directory is not in the mount table.
227.It Bq Er EBUSY
228A process is holding a reference to a file located
229on the filesystem.
230.It Bq Er EIO
231An I/O error occurred while writing cached filesystem information.
232.It Bq Er EFAULT
233.Fa Dir
234points outside the process's allocated address space.
235.El
9bccf70c
A
236.Sh SEE ALSO
237.Xr mount 8 ,
5ba3f43e
A
238.Xr unmount 8 ,
239.Xr open 2
9bccf70c
A
240.Sh BUGS
241Some of the error codes need translation to more obvious messages.
242.Sh HISTORY
39037602 243.Fn mount
9bccf70c 244and
3e170ce0 245.Fn unmount
9bccf70c
A
246function calls appeared in
247.At v6 .
5ba3f43e
A
248.Fn fmount
249function call first appeared in macOS version 10.13.