]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/mount.2
added FIXME
[thirdparty/man-pages.git] / man2 / mount.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
4 .\" Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
5 .\" Copyright (C) 2002, 2005 Michael Kerrisk <mtk-manpages@gmx.net>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-10-13 by Michael Kerrisk <mtk-manpages@gmx.net>
29 .\" Added note on historical behaviour of MS_NOSUID
30 .\" Modified 2002-05-16 by Michael Kerrisk <mtk-manpages@gmx.net>
31 .\" Extensive changes and additions
32 .\" Modified 2002-05-27 by aeb
33 .\" Modified 2002-06-11 by Michael Kerrisk <mtk-manpages@gmx.net>
34 .\" Enhanced descriptions of MS_MOVE, MS_BIND, and MS_REMOUNT
35 .\" Modified 2004-06-17 by Michael Kerrisk <mtk-manpages@gmx.net>
36 .\" 2005-05-18, mtk, Added MNT_EXPIRE, plus a few other tidy-ups.
37 .\"
38 .TH MOUNT 2 2004-05-18 "Linux 2.6.12" "Linux Programmer's Manual"
39 .SH NAME
40 mount, umount \- mount and unmount filesystems
41 .SH SYNOPSIS
42 .nf
43 .B "#include <sys/mount.h>"
44 .sp
45 .BI "int mount(const char *" source ", const char *" target ,
46 .BI " const char *" filesystemtype ", unsigned long " mountflags ,
47 .BI " const void *" data );
48 .sp
49 .BI "int umount(const char *" target );
50 .sp
51 .BI "int umount2(const char *" target ", int " flags );
52 .fi
53 .SH DESCRIPTION
54 .BR mount ()
55 attaches the filesystem specified by
56 .I source
57 (which is often a device name, but can also be a directory name
58 or a dummy) to the directory specified by
59 .IR target .
60
61 .BR umount ()
62 and
63 .BR umount2 ()
64 remove the attachment of the (topmost) filesystem mounted on
65 .IR target .
66
67 Appropriate privilege (Linux: the
68 .B CAP_SYS_ADMIN
69 capability) is required to mount and unmount filesystems.
70
71 Since Linux 2.4 a single filesystem can be visible at
72 multiple mount points, and multiple mounts can be stacked
73 on the same mount point.
74 .\" Multiple mounts on same mount point: since 2.3.99pre7.
75
76 Values for the
77 .IR filesystemtype
78 argument supported by the kernel are listed in
79 .I /proc/filesystems
80 (like "minix", "ext2", "msdos", "proc", "nfs", "iso9660" etc.).
81 Further types may become available when the appropriate modules
82 are loaded.
83
84 The
85 .IR mountflags
86 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
87 in the top 16 bits (this was required in kernel versions prior to 2.4, but
88 is no longer required and ignored if specified),
89 and various mount flags (as defined in <linux/fs.h> for libc4 and libc5
90 and in <sys/mount.h> for glibc2) in the low order 16 bits:
91 .\" FIXME 2.6.15 added flags for "shared sub-tree" functionality:
92 .\" MS_UNBINDABLE, MS_PRIVATE, MS_SHARED, MS_SLAVE
93 .\" These need to be documented on this page.
94 .\" See Documentation/sharedsubtree.txt
95 .TP
96 .B MS_BIND
97 (Linux 2.4 onwards)
98 .\" since 2.4.0-test9
99 Perform a bind mount, making a file or a directory subtree visible at
100 another point within a file system.
101 Bind mounts may cross file system boundaries and span
102 .BR chroot (2)
103 jails.
104 The
105 .IR filesystemtype ", " mountflags ", and " data
106 arguments are ignored.
107 .\" with the exception of the "hidden" MS_REC mountflags bit
108 .TP
109 .BR MS_DIRSYNC " (since Linux 2.5.19)"
110 Make directory changes on this file system synchronous.
111 (This property can be obtained for individual directories
112 or subtrees using
113 .BR chattr (8).)
114 .TP
115 .B MS_MANDLOCK
116 Permit mandatory locking on files in this file system.
117 (Mandatory locking must still be enabled on a per-file basis,
118 as described in
119 .BR fcntl (2).)
120 .\" FIXME Say more about MS_MOVE
121 .TP
122 .B MS_MOVE
123 Move a subtree.
124 .I source
125 specifies an existing mount point and
126 .I target
127 specifies the new location.
128 The move is atomic: at no point is the subtree unmounted.
129 The
130 .IR filesystemtype ", " mountflags ", and " data
131 arguments are ignored.
132 .TP
133 .B MS_NOATIME
134 Do not update access times for (all types of) files on this file system.
135 .TP
136 .B MS_NODEV
137 Do not allow access to devices (special files) on this file system.
138 .TP
139 .B MS_NODIRATIME
140 Do not update access times for directories on this file system.
141 .TP
142 .B MS_NOEXEC
143 Do not allow programs to be executed from this file system.
144 .\" (Possibly useful for a file system that contains non-Linux executables.
145 .\" Often used as a security feature, e.g. to make sure that restricted
146 .\" users cannot execute files uploaded using ftp or so.)
147 .TP
148 .B MS_NOSUID
149 Do not honour set-user-ID and set-group-ID bits when executing
150 programs from this file system.
151 .\" (This is a security feature to prevent users executing set-user-ID and
152 .\" set-group-ID programs from removable disk devices.)
153 .TP
154 .B MS_RDONLY
155 Mount file system read-only.
156 .\"
157 .\" FIXME Document MS_REC, available since 2.4.11.
158 .\" This flag has meaning in conjunction with MS_BIND and
159 .\" also with the shared sub-tree flags.
160 .TP
161 .B MS_REMOUNT
162 Remount an existing mount. This is allows you to change the
163 .I mountflags
164 and
165 .I data
166 of an existing mount without having to unmount and remount the file system.
167 .I source
168 and
169 .I target
170 should be the same values specified in the initial
171 .BR mount ()
172 call;
173 .I filesystemtype
174 is ignored.
175 .TP
176 .B MS_SYNCHRONOUS
177 Make writes on this file system synchronous (as though
178 the
179 .B O_SYNC
180 flag to
181 .BR open (2)
182 was specified for all file opens to this file system).
183 .PP
184 From Linux 2.4 onwards, the
185 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
186 flags are settable on a per-mount-point basis.
187 Form kernel 2.6.16 onwards,
188 .B MS_NOATIME
189 and
190 .B MS_NODIRATIME
191 are also settable on a per-mount-point basis.
192 .\" FIXME Since Linux 2.6.16, MS_NODIRATIME and MS_NOATIME are
193 .\" also settable on a per-mount basis
194 .PP
195 The
196 .IR data
197 argument is interpreted by the different file systems.
198 Typically it is a string of comma-separated options
199 understood by this file system.
200 See
201 .BR mount (8)
202 for details of the options available for each filesystem type.
203 .PP
204 .\" Note: the kernel naming differs from the glibc naming
205 .\" umount2 is the glibc name for what the kernel now calls umount
206 .\" and umount is the glibc name for oldumount
207 Linux 2.1.116 added the
208 .BR umount2 ()
209 system call, which, like
210 .BR umount (),
211 unmounts a target, but allows additional
212 .I flags
213 controlling the behaviour of the operation:
214 .TP
215 .BR MNT_FORCE " (since Linux 2.1.116)"
216 Force unmount even if busy.
217 (Only for NFS mounts.)
218 .\" FIXME Can MNT_FORCE result in data loss? According to
219 .\" the Solaris manual page it can cause data loss on Solaris.
220 .\" If the same holds on Linux, then this should be documented.
221 .TP
222 .BR MNT_DETACH " (since Linux 2.4.11)"
223 Perform a lazy unmount: make the mount point unavailable for
224 new accesses, and actually perform the unmount when the mount point
225 ceases to be busy.
226 .TP
227 .BR MNT_EXPIRE " (since Linux 2.6.8)"
228 Mark the mount point as expired.
229 If a mount point is not currently in use, then an initial call to
230 .BR umount2 ()
231 with this flag fails with the error
232 .BR EAGAIN ,
233 but marks the mount point as expired.
234 The mount point remains expired as long as it isn't accessed
235 by any process.
236 A second
237 .BR umount2 ()
238 call specifying
239 .B MNT_EXPIRE
240 unmounts an expired mount point.
241 This flag cannot be specified with either
242 .B MNT_FORCE
243 or
244 .BR MNT_DETACH .
245 .SH "RETURN VALUE"
246 On success, zero is returned. On error, \-1 is returned, and
247 .I errno
248 is set appropriately.
249 .SH ERRORS
250 The error values given below result from filesystem type independent
251 errors. Each filesystem type may have its own special errors and its
252 own special behavior. See the kernel source code for details.
253
254 .TP
255 .B EACCES
256 A component of a path was not searchable. (See also
257 .BR path_resolution (2).)
258 Or, mounting a read-only filesystem was attempted without giving the
259 .B MS_RDONLY
260 flag.
261 Or, the block device
262 .I source
263 is located on a filesystem mounted with the
264 .B MS_NODEV
265 option.
266 .\" mtk: Probably: write permission is required for MS_BIND, with
267 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
268 .TP
269 .B EAGAIN
270 A call to
271 .BR umount2 ()
272 specifying
273 .B MNT_EXPIRE
274 successfully marked an unbusy file system as expired.
275 .TP
276 .B EBUSY
277 .I source
278 is already mounted. Or, it cannot be remounted read-only,
279 because it still holds files open for writing.
280 Or, it cannot be mounted on
281 .I target
282 because
283 .I target
284 is still busy (it is the working directory of some task,
285 the mount point of another device, has open files, etc.).
286 Or, it could not be unmounted because it is busy.
287 .TP
288 .B EFAULT
289 One of the pointer arguments points outside the user address space.
290 .TP
291 .B EINVAL
292 .I source
293 had an invalid superblock.
294 Or, a remount
295 .RB ( MS_REMOUNT )
296 was attempted, but
297 .I source
298 was not already mounted on
299 .IR target .
300 Or, a move
301 .RB ( MS_MOVE )
302 was attempted, but
303 .I source
304 was not a mount point, or was '/'.
305 Or, an unmount was attempted, but
306 .I target
307 was not a mount point.
308 Or,
309 .BR umount2 ()
310 was called with
311 .B MNT_FORCE
312 and either
313 .B MNT_DETACH
314 or
315 .BR MNT_FORCE .
316 .TP
317 .B ELOOP
318 Too many link encountered during pathname resolution.
319 Or, a move was attempted, while
320 .I target
321 is a descendant of
322 .IR source .
323 .TP
324 .B EMFILE
325 (In case no block device is required:)
326 Table of dummy devices is full.
327 .TP
328 .B ENAMETOOLONG
329 A pathname was longer than MAXPATHLEN.
330 .TP
331 .B ENODEV
332 .I Filesystemtype
333 not configured in the kernel.
334 .TP
335 .B ENOENT
336 A pathname was empty or had a nonexistent component.
337 .TP
338 .B ENOMEM
339 The kernel could not allocate a free page to copy filenames or data into.
340 .TP
341 .B ENOTBLK
342 .I source
343 is not a block device (and a device was required).
344 .TP
345 .B ENOTDIR
346 The second argument, or a prefix of the first argument, is not
347 a directory.
348 .TP
349 .B ENXIO
350 The major number of the block device
351 .I source
352 is out of range.
353 .TP
354 .B EPERM
355 The caller does not have the required privileges.
356 .SH "CONFORMING TO"
357 These functions are Linux-specific and should not be used in
358 programs intended to be portable.
359 .SH HISTORY
360 The original
361 .BR umount ()
362 function was called as \fIumount(device)\fP and would return ENOTBLK
363 when called with something other than a block device.
364 In Linux 0.98p4 a call \fIumount(dir)\fP was added, in order to
365 support anonymous devices.
366 In Linux 2.3.99-pre7 the call \fIumount(device)\fP was removed,
367 leaving only \fIumount(dir)\fP (since now devices can be mounted
368 in more than one place, so specifying the device does not suffice).
369 .LP
370 The original MS_SYNC flag was renamed MS_SYNCHRONOUS in 1.1.69
371 when a different MS_SYNC was added to <mman.h>.
372 .LP
373 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
374 on a filesystem mounted with
375 .B MS_NOSUID
376 would fail with
377 .BR EPERM .
378 Since Linux 2.4 the set-user-ID and set-group-ID bits are
379 just silently ignored in this case.
380 .\" The change is in patch-2.4.0-prerelease.
381 .SH "SEE ALSO"
382 .BR path_resolution (2),
383 .BR mount (8),
384 .BR umount (8)