]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/mount.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / mount.2
1 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
2 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
3 .\" and Copyright (C) 2002, 2005, 2016 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-10-13 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Added note on historical behavior of MS_NOSUID
30 .\" Modified 2002-05-16 by Michael Kerrisk <mtk.manpages@gmail.com>
31 .\" Extensive changes and additions
32 .\" Modified 2002-05-27 by aeb
33 .\" Modified 2002-06-11 by Michael Kerrisk <mtk.manpages@gmail.com>
34 .\" Enhanced descriptions of MS_MOVE, MS_BIND, and MS_REMOUNT
35 .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
36 .\" 2005-05-18, mtk, Added MNT_EXPIRE, plus a few other tidy-ups.
37 .\" 2008-10-06, mtk: move umount*() material into separate umount.2 page.
38 .\" 2008-10-06, mtk: Add discussion of namespaces.
39 .\"
40 .TH MOUNT 2 2019-08-02 "Linux" "Linux Programmer's Manual"
41 .SH NAME
42 mount \- mount filesystem
43 .SH SYNOPSIS
44 .nf
45 .B "#include <sys/mount.h>"
46 .PP
47 .BI "int mount(const char *" source ", const char *" target ,
48 .BI " const char *" filesystemtype ", unsigned long " mountflags ,
49 .BI " const void *" data );
50 .fi
51 .SH DESCRIPTION
52 .BR mount ()
53 attaches the filesystem specified by
54 .I source
55 (which is often a pathname referring to a device,
56 but can also be the pathname of a directory or file,
57 or a dummy string) to the location (a directory or file)
58 specified by the pathname in
59 .IR target .
60 .PP
61 Appropriate privilege (Linux: the
62 .B CAP_SYS_ADMIN
63 capability) is required to mount filesystems.
64 .PP
65 Values for the
66 .I filesystemtype
67 argument supported by the kernel are listed in
68 .I /proc/filesystems
69 (e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse",
70 "tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs", "iso9660").
71 Further types may become available when the appropriate modules
72 are loaded.
73 .PP
74 The
75 .I data
76 argument is interpreted by the different filesystems.
77 Typically it is a string of comma-separated options
78 understood by this filesystem.
79 See
80 .BR mount (8)
81 for details of the options available for each filesystem type.
82 .PP
83 A call to
84 .BR mount ()
85 performs one of a number of general types of operation,
86 depending on the bits specified in
87 .IR mountflags .
88 The choice of which operation to perform is determined by
89 testing the bits set in
90 .IR mountflags ,
91 with the tests being conducted in the order listed here:
92 .IP * 3
93 Remount an existing mount:
94 .IR mountflags
95 includes
96 .BR MS_REMOUNT .
97 .IP *
98 Create a bind mount:
99 .IR mountflags
100 includes
101 .BR MS_BIND .
102 .IP *
103 Change the propagation type of an existing mount:
104 .IR mountflags
105 includes one of
106 .BR MS_SHARED ,
107 .BR MS_PRIVATE ,
108 .BR MS_SLAVE ,
109 or
110 .BR MS_UNBINDABLE .
111 .IP *
112 Move an existing mount to a new location:
113 .IR mountflags
114 includes
115 .BR MS_MOVE .
116 .IP *
117 Create a new mount:
118 .IR mountflags
119 includes none of the above flags.
120 .PP
121 Each of these operations is detailed later in this page.
122 Further flags may be specified in
123 .IR mountflags
124 to modify the behavior of
125 .BR mount (),
126 as described below.
127 .\"
128 .SS Additional mount flags
129 The list below describes the additional flags that can be specified in
130 .IR mountflags .
131 Note that some operation types ignore some or all of these flags,
132 as described later in this page.
133 .\"
134 .\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented.
135 .\" commit 7a224228ed79d587ece2304869000aad1b8e97dd
136 .\" (This is a per-superblock flag)
137 .\"
138 .TP
139 .BR MS_DIRSYNC " (since Linux 2.5.19)"
140 Make directory changes on this filesystem synchronous.
141 (This property can be obtained for individual directories
142 or subtrees using
143 .BR chattr (1).)
144 .TP
145 .BR MS_LAZYTIME " (since Linux 4.0)"
146 .\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8
147 .\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6
148 .\" commit a26f49926da938f47561f386be56a83dd37a496d
149 Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
150 by maintaining these changes only in memory.
151 The on-disk timestamps are updated only when:
152 .RS
153 .IP (a) 5
154 the inode needs to be updated for some change unrelated to file timestamps;
155 .IP (b)
156 the application employs
157 .BR fsync (2),
158 .BR syncfs (2),
159 or
160 .BR sync (2);
161 .IP (c)
162 an undeleted inode is evicted from memory; or
163 .IP (d)
164 more than 24 hours have passed since the inode was written to disk.
165 .RE
166 .IP
167 This mount option significantly reduces writes
168 needed to update the inode's timestamps, especially mtime and atime.
169 However, in the event of a system crash, the atime and mtime fields
170 on disk might be out of date by up to 24 hours.
171 .IP
172 Examples of workloads where this option could be of significant benefit
173 include frequent random writes to preallocated files,
174 as well as cases where the
175 .B MS_STRICTATIME
176 mount option is also enabled.
177 (The advantage of combining
178 .BR MS_STRICTATIME
179 and
180 .BR MS_LAZYTIME
181 is that
182 .BR stat (2)
183 will return the correctly updated atime, but the atime updates
184 will be flushed to disk only in the cases listed above.)
185 .TP
186 .B MS_MANDLOCK
187 Permit mandatory locking on files in this filesystem.
188 (Mandatory locking must still be enabled on a per-file basis,
189 as described in
190 .BR fcntl (2).)
191 Since Linux 4.5,
192 .\" commit 95ace75414f312f9a7b93d873f386987b92a5301
193 this mount option requires the
194 .B CAP_SYS_ADMIN
195 capability and a kernel configured with the
196 .B CONFIG_MANDATORY_FILE_LOCKING
197 option.
198 .TP
199 .B MS_NOATIME
200 Do not update access times for (all types of) files on this filesystem.
201 .TP
202 .B MS_NODEV
203 Do not allow access to devices (special files) on this filesystem.
204 .TP
205 .B MS_NODIRATIME
206 Do not update access times for directories on this filesystem.
207 This flag provides a subset of the functionality provided by
208 .BR MS_NOATIME ;
209 that is,
210 .BR MS_NOATIME
211 implies
212 .BR MS_NODIRATIME .
213 .TP
214 .B MS_NOEXEC
215 Do not allow programs to be executed from this filesystem.
216 .\" (Possibly useful for a filesystem that contains non-Linux executables.
217 .\" Often used as a security feature, e.g., to make sure that restricted
218 .\" users cannot execute files uploaded using ftp or so.)
219 .TP
220 .B MS_NOSUID
221 Do not honor set-user-ID and set-group-ID bits or file capabilities
222 when executing programs from this filesystem.
223 .\" (This is a security feature to prevent users executing set-user-ID and
224 .\" set-group-ID programs from removable disk devices.)
225 .TP
226 .B MS_RDONLY
227 Mount filesystem read-only.
228 .TP
229 .BR MS_REC " (since Linux 2.4.11)"
230 Used in conjunction with
231 .BR MS_BIND
232 to create a recursive bind mount,
233 and in conjunction with the propagation type flags to recursively change
234 the propagation type of all of the mounts in a subtree.
235 See below for further details.
236 .TP
237 .BR MS_RELATIME " (since Linux 2.6.20)"
238 When a file on this filesystem is accessed,
239 update the file's last access time (atime) only if the current value
240 of atime is less than or equal to the file's last modification time (mtime)
241 or last status change time (ctime).
242 This option is useful for programs, such as
243 .BR mutt (1),
244 that need to know when a file has been read since it was last modified.
245 Since Linux 2.6.30, the kernel defaults to the behavior provided
246 by this flag (unless
247 .BR MS_NOATIME
248 was specified), and the
249 .B MS_STRICTATIME
250 flag is required to obtain traditional semantics.
251 In addition, since Linux 2.6.30,
252 the file's last access time is always updated if it
253 is more than 1 day old.
254 .\" Matthew Garrett notes in the patch that added this behavior
255 .\" that this lets utilities such as tmpreaper (which deletes
256 .\" files based on last access time) work correctly.
257 .TP
258 .BR MS_SILENT " (since Linux 2.6.17)"
259 Suppress the display of certain
260 .RI ( printk ())
261 warning messages in the kernel log.
262 This flag supersedes the misnamed and obsolete
263 .BR MS_VERBOSE
264 flag (available since Linux 2.4.12), which has the same meaning.
265 .TP
266 .BR MS_STRICTATIME " (since Linux 2.6.30)"
267 Always update the last access time (atime) when files on this
268 filesystem are accessed.
269 (This was the default behavior before Linux 2.6.30.)
270 Specifying this flag overrides the effect of setting the
271 .BR MS_NOATIME
272 and
273 .BR MS_RELATIME
274 flags.
275 .TP
276 .B MS_SYNCHRONOUS
277 Make writes on this filesystem synchronous (as though
278 the
279 .B O_SYNC
280 flag to
281 .BR open (2)
282 was specified for all file opens to this filesystem).
283 .PP
284 From Linux 2.4 onward, some of the above flags are
285 settable on a per-mount basis,
286 while others apply to the superblock of the mounted filesystem,
287 meaning that all mounts of the same filesystem share those flags.
288 (Previously, all of the flags were per-superblock.)
289 .PP
290 The per-mount-point flags are as follows:
291 .IP * 3
292 Since Linux 2.4:
293 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
294 flags are settable on a per-mount-point basis.
295 .IP *
296 Since Linux 2.6.16:
297 .B MS_NOATIME
298 and
299 .BR MS_NODIRATIME .
300 .IP *
301 Since Linux 2.6.20:
302 .BR MS_RELATIME .
303 .PP
304 The following flags are per-superblock:
305 .BR MS_DIRSYNC ,
306 .BR MS_LAZYTIME ,
307 .BR MS_MANDLOCK ,
308 .BR MS_SILENT ,
309 and
310 .BR MS_SYNCHRONOUS .
311 .\" And MS_I_VERSION?
312 The initial settings of these flags are determined on the first
313 mount of the filesystem, and will be shared by all subsequent mounts
314 of the same filesystem.
315 Subsequently, the settings of the flags can be changed
316 via a remount operation (see below).
317 Such changes will be visible via all mount points associated
318 with the filesystem.
319 .PP
320 Since Linux 2.6.16,
321 .B MS_RDONLY
322 can be set or cleared on a per-mount-point basis as well as on
323 the underlying filesystem superblock.
324 The mounted filesystem will be writable only if neither the filesystem
325 nor the mountpoint are flagged as read-only.
326 .\"
327 .SS Remounting an existing mount
328 An existing mount may be remounted by specifying
329 .B MS_REMOUNT
330 in
331 .IR mountflags .
332 This allows you to change the
333 .I mountflags
334 and
335 .I data
336 of an existing mount without having to unmount and remount the filesystem.
337 .I target
338 should be the same value specified in the initial
339 .BR mount ()
340 call.
341 .PP
342 The
343 .I source
344 and
345 .I filesystemtype
346 arguments are ignored.
347 .PP
348 The
349 .I mountflags
350 and
351 .I data
352 arguments should match the values used in the original
353 .BR mount ()
354 call, except for those parameters that are being deliberately changed.
355 .PP
356 The following
357 .I mountflags
358 can be changed:
359 .BR MS_LAZYTIME ,
360 .\" FIXME
361 .\" MS_LAZYTIME seems to be available only on a few filesystems,
362 .\" and on ext4, it seems (from experiment that this flag
363 .\" can only be enabled (but not disabled) on a remount.
364 .\" The following code in ext4_remount() (kernel 4.17) seems to
365 .\" confirm this:
366 .\"
367 .\" if (*flags & SB_LAZYTIME)
368 .\" sb->s_flags |= SB_LAZYTIME;
369 .BR MS_MANDLOCK ,
370 .BR MS_NOATIME ,
371 .BR MS_NODEV ,
372 .BR MS_NODIRATIME ,
373 .BR MS_NOEXEC ,
374 .BR MS_NOSUID ,
375 .BR MS_RELATIME ,
376 .BR MS_RDONLY ,
377 .BR MS_STRICTATIME
378 (whose effect is to clear the
379 .BR MS_NOATIME
380 and
381 .BR MS_RELATIME
382 flags),
383 and
384 .BR MS_SYNCHRONOUS .
385 Attempts to change the setting of the
386 .\" See the definition of MS_RMT_MASK in include/uapi/linux/fs.h,
387 .\" which excludes MS_DIRSYNC and MS_SILENT, although SB_DIRSYNC
388 .\" and SB_SILENT are split out as per-superblock flags in do_mount()
389 .\" (Linux 4.17 source code)
390 .BR MS_DIRSYNC
391 and
392 .BR MS_SILENT
393 flags during a remount are silently ignored.
394 Note that changes to per-superblock flags are visible via
395 all mount points of the associated filesystem
396 (because the per-superblock flags are shared by all mount points).
397 .PP
398 Since Linux 3.17,
399 .\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e
400 if none of
401 .BR MS_NOATIME ,
402 .BR MS_NODIRATIME ,
403 .BR MS_RELATIME ,
404 or
405 .BR MS_STRICTATIME
406 is specified in
407 .IR mountflags ,
408 then the remount operation preserves the existing values of these flags
409 (rather than defaulting to
410 .BR MS_RELATIME ).
411 .PP
412 Since Linux 2.6.26, the
413 .B MS_REMOUNT
414 flag can be used with
415 .B MS_BIND
416 to modify only the per-mount-point flags.
417 .\" See https://lwn.net/Articles/281157/
418 This is particularly useful for setting or clearing the "read-only"
419 flag on a mount point without changing the underlying filesystem.
420 Specifying
421 .IR mountflags
422 as:
423 .PP
424 .in +4n
425 .EX
426 MS_REMOUNT | MS_BIND | MS_RDONLY
427 .EE
428 .in
429 .PP
430 will make access through this mountpoint read-only, without affecting
431 other mount points.
432 .\"
433 .SS Creating a bind mount
434 If
435 .I mountflags
436 includes
437 .BR MS_BIND
438 (available since Linux 2.4),
439 .\" since 2.4.0-test9
440 then perform a bind mount.
441 A bind mount makes a file or a directory subtree visible at
442 another point within the single directory hierarchy.
443 Bind mounts may cross filesystem boundaries and span
444 .BR chroot (2)
445 jails.
446 .PP
447 The
448 .IR filesystemtype
449 and
450 .IR data
451 arguments are ignored.
452 .PP
453 The remaining bits (other than
454 .BR MS_REC ,
455 described below) in the
456 .I mountflags
457 argument are also ignored.
458 (The bind mount has the same mount options as
459 the underlying mount point.)
460 However, see the discussion of remounting above,
461 for a method of making an existing bind mount read-only.
462 .PP
463 By default, when a directory is bind mounted,
464 only that directory is mounted;
465 if there are any submounts under the directory tree,
466 they are not bind mounted.
467 If the
468 .BR MS_REC
469 flag is also specified, then a recursive bind mount operation is performed:
470 all submounts under the
471 .I source
472 subtree (other than unbindable mounts)
473 are also bind mounted at the corresponding location in the
474 .I target
475 subtree.
476 .\"
477 .SS Changing the propagation type of an existing mount
478 If
479 .IR mountflags
480 includes one of
481 .BR MS_SHARED ,
482 .BR MS_PRIVATE ,
483 .BR MS_SLAVE ,
484 or
485 .BR MS_UNBINDABLE
486 (all available since Linux 2.6.15),
487 then the propagation type of an existing mount is changed.
488 If more than one of these flags is specified, an error results.
489 .PP
490 The only other flags that can be specified while changing
491 the propagation type are
492 .BR MS_REC
493 (described below) and
494 .BR MS_SILENT
495 (which is ignored).
496 .PP
497 The
498 .IR source ,
499 .IR filesystemtype ,
500 and
501 .IR data
502 arguments are ignored.
503 .PP
504 The meanings of the propagation type flags are as follows:
505 .TP
506 .BR MS_SHARED
507 Make this mount point shared.
508 Mount and unmount events immediately under this mount point will propagate
509 to the other mount points that are members of this mount's peer group.
510 Propagation here means that the same mount or unmount will automatically
511 occur under all of the other mount points in the peer group.
512 Conversely, mount and unmount events that take place under
513 peer mount points will propagate to this mount point.
514 .TP
515 .BR MS_PRIVATE
516 Make this mount point private.
517 Mount and unmount events do not propagate into or out of this mount point.
518 .TP
519 .BR MS_SLAVE
520 If this is a shared mount point that is a member of a peer group
521 that contains other members, convert it to a slave mount.
522 If this is a shared mount point that is a member of a peer group
523 that contains no other members, convert it to a private mount.
524 Otherwise, the propagation type of the mount point is left unchanged.
525 .IP
526 When a mount point is a slave,
527 mount and unmount events propagate into this mount point from
528 the (master) shared peer group of which it was formerly a member.
529 Mount and unmount events under this mount point do not propagate to any peer.
530 .IP
531 A mount point can be the slave of another peer group
532 while at the same time sharing mount and unmount events
533 with a peer group of which it is a member.
534 .TP
535 .BR MS_UNBINDABLE
536 Make this mount unbindable.
537 This is like a private mount,
538 and in addition this mount can't be bind mounted.
539 When a recursive bind mount
540 .RB ( mount ()
541 with the
542 .BR MS_BIND
543 and
544 .BR MS_REC
545 flags) is performed on a directory subtree,
546 any unbindable mounts within the subtree are automatically pruned
547 (i.e., not replicated)
548 when replicating that subtree to produce the target subtree.
549 .PP
550 By default, changing the propagation type affects only the
551 .I target
552 mount point.
553 If the
554 .B MS_REC
555 flag is also specified in
556 .IR mountflags ,
557 then the propagation type of all mount points under
558 .IR target
559 is also changed.
560 .PP
561 For further details regarding mount propagation types
562 (including the default propagation type assigned to new mounts), see
563 .BR mount_namespaces (7).
564 .\"
565 .SS Moving a mount
566 If
567 .I mountflags
568 contains the flag
569 .BR MS_MOVE
570 (available since Linux 2.4.18),
571 then move a subtree:
572 .I source
573 specifies an existing mount point and
574 .I target
575 specifies the new location to which that mount point is to be relocated.
576 The move is atomic: at no point is the subtree unmounted.
577 .PP
578 The remaining bits in the
579 .IR mountflags
580 argument are ignored, as are the
581 .IR filesystemtype
582 and
583 .IR data
584 arguments.
585 .\"
586 .SS Creating a new mount point
587 If none of
588 .BR MS_REMOUNT ,
589 .BR MS_BIND ,
590 .BR MS_MOVE ,
591 .BR MS_SHARED ,
592 .BR MS_PRIVATE ,
593 .BR MS_SLAVE ,
594 or
595 .BR MS_UNBINDABLE
596 is specified in
597 .IR mountflags ,
598 then
599 .BR mount ()
600 performs its default action: creating a new mount point.
601 .IR source
602 specifies the source for the new mount point, and
603 .IR target
604 specifies the directory at which to create the mount point.
605 .PP
606 The
607 .I filesystemtype
608 and
609 .I data
610 arguments are employed, and further bits may be specified in
611 .IR mountflags
612 to modify the behavior of the call.
613 .\"
614 .SH RETURN VALUE
615 On success, zero is returned.
616 On error, \-1 is returned, and
617 .I errno
618 is set appropriately.
619 .SH ERRORS
620 The error values given below result from filesystem type independent
621 errors.
622 Each filesystem type may have its own special errors and its
623 own special behavior.
624 See the Linux kernel source code for details.
625 .TP
626 .B EACCES
627 A component of a path was not searchable.
628 (See also
629 .BR path_resolution (7).)
630 .TP
631 .B EACCES
632 Mounting a read-only filesystem was attempted without giving the
633 .B MS_RDONLY
634 flag.
635 .IP
636 The filesystem may be read-only for various reasons, including:
637 it resides on a read-only optical disk;
638 it is resides on a device with a physical switch that has been set to
639 mark the device read-only;
640 the filesystem implementation was compiled with read-only support;
641 or errors were detected when initially mounting the filesystem,
642 so that it was marked read-only
643 and can't be remounted as read-write (until the errors are fixed).
644 .IP
645 Some filesystems instead return the error
646 .BR EROFS
647 on an attempt to mount a read-only filesystem.
648 .TP
649 .B EACCES
650 The block device
651 .I source
652 is located on a filesystem mounted with the
653 .B MS_NODEV
654 option.
655 .\" mtk: Probably: write permission is required for MS_BIND, with
656 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
657 .TP
658 .B EBUSY
659 An attempt was made to stack a new mount directly on
660 top of an existing mount point that was created in this
661 mount namespace with the same
662 .I source
663 and
664 .IR target .
665 .TP
666 .B EBUSY
667 .I source
668 cannot be remounted read-only,
669 because it still holds files open for writing.
670 .TP
671 .B EFAULT
672 One of the pointer arguments points outside the user address space.
673 .TP
674 .B EINVAL
675 .I source
676 had an invalid superblock.
677 .TP
678 .B EINVAL
679 A remount operation
680 .RB ( MS_REMOUNT )
681 was attempted, but
682 .I source
683 was not already mounted on
684 .IR target .
685 .TP
686 .B EINVAL
687 A move operation
688 .RB ( MS_MOVE )
689 was attempted, but the mount tree under
690 .I source
691 includes unbindable mounts and
692 .I target
693 is a mount point that has propagation type
694 .BR MS_SHARED .
695 .TP
696 .B EINVAL
697 A move operation
698 .RB ( MS_MOVE )
699 was attempted, but the parent mount of
700 .I source
701 mount has propagation type
702 .BR MS_SHARED .
703 .TP
704 .B EINVAL
705 A move operation
706 .RB ( MS_MOVE )
707 was attempted, but
708 .I source
709 was not a mount point, or was \(aq/\(aq.
710 .TP
711 .B EINVAL
712 .I mountflags
713 includes more than one of
714 .BR MS_SHARED ,
715 .BR MS_PRIVATE ,
716 .BR MS_SLAVE ,
717 or
718 .BR MS_UNBINDABLE .
719 .TP
720 .B EINVAL
721 .I mountflags
722 includes
723 .BR MS_SHARED ,
724 .BR MS_PRIVATE ,
725 .BR MS_SLAVE ,
726 or
727 .BR MS_UNBINDABLE
728 and also includes a flag other than
729 .BR MS_REC
730 or
731 .BR MS_SILENT .
732 .TP
733 .BR EINVAL
734 An attempt was made to bind mount an unbindable mount.
735 .TP
736 .BR EINVAL
737 In an unprivileged mount namespace
738 (i.e., a mount namespace owned by a user namespace
739 that was created by an unprivileged user),
740 a bind mount operation
741 .RB ( MS_BIND )
742 was attempted without specifying
743 .RB ( MS_REC ),
744 which would have revealed the filesystem tree underneath one of
745 the submounts of the directory being bound.
746 .TP
747 .B ELOOP
748 Too many links encountered during pathname resolution.
749 .TP
750 .B ELOOP
751 A move operation was attempted, and
752 .I target
753 is a descendant of
754 .IR source .
755 .TP
756 .B EMFILE
757 (In case no block device is required:)
758 Table of dummy devices is full.
759 .TP
760 .B ENAMETOOLONG
761 A pathname was longer than
762 .BR MAXPATHLEN .
763 .TP
764 .B ENODEV
765 .I filesystemtype
766 not configured in the kernel.
767 .TP
768 .B ENOENT
769 A pathname was empty or had a nonexistent component.
770 .TP
771 .B ENOMEM
772 The kernel could not allocate a free page to copy filenames or data into.
773 .TP
774 .B ENOTBLK
775 .I source
776 is not a block device (and a device was required).
777 .TP
778 .B ENOTDIR
779 .IR target ,
780 or a prefix of
781 .IR source ,
782 is not a directory.
783 .TP
784 .B ENXIO
785 The major number of the block device
786 .I source
787 is out of range.
788 .TP
789 .B EPERM
790 The caller does not have the required privileges.
791 .TP
792 .B EROFS
793 Mounting a read-only filesystem was attempted without giving the
794 .B MS_RDONLY
795 flag.
796 See
797 .BR EACCES ,
798 above.
799 .SH VERSIONS
800 The definitions of
801 .BR MS_DIRSYNC ,
802 .BR MS_MOVE ,
803 .BR MS_PRIVATE ,
804 .BR MS_REC ,
805 .BR MS_RELATIME ,
806 .BR MS_SHARED ,
807 .BR MS_SLAVE ,
808 .BR MS_STRICTATIME ,
809 and
810 .BR MS_UNBINDABLE
811 were added to glibc headers in version 2.12.
812 .\"
813 .SH CONFORMING TO
814 This function is Linux-specific and should not be used in
815 programs intended to be portable.
816 .SH NOTES
817 Since Linux 2.4 a single filesystem can be mounted at
818 multiple mount points, and multiple mounts can be stacked
819 on the same mount point.
820 .\" Multiple mounts on same mount point: since 2.3.99pre7.
821 .PP
822 The
823 .I mountflags
824 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
825 in the top 16 bits.
826 (All of the other flags discussed in DESCRIPTION
827 occupy the low order 16 bits of
828 .IR mountflags .)
829 Specifying
830 .BR MS_MGC_VAL
831 was required in kernel versions prior to 2.4,
832 but since Linux 2.4 is no longer required and is ignored if specified.
833 .PP
834 The original
835 .B MS_SYNC
836 flag was renamed
837 .B MS_SYNCHRONOUS
838 in 1.1.69
839 when a different
840 .B MS_SYNC
841 was added to \fI<mman.h>\fP.
842 .PP
843 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
844 on a filesystem mounted with
845 .B MS_NOSUID
846 would fail with
847 .BR EPERM .
848 Since Linux 2.4 the set-user-ID and set-group-ID bits are
849 just silently ignored in this case.
850 .\" The change is in patch-2.4.0-prerelease.
851 .\"
852 .SS Mount namespaces
853 Starting with kernel 2.4.19, Linux provides mount namespaces.
854 A mount namespace is the set of filesystem mounts that
855 are visible to a process.
856 Mount namespaces can be (and usually are)
857 shared between multiple processes,
858 and changes to the namespace (i.e., mounts and unmounts) by one process
859 are visible to all other processes sharing the same namespace.
860 (The pre-2.4.19 Linux situation can be considered as one in which
861 a single namespace was shared by every process on the system.)
862 .PP
863 A child process created by
864 .BR fork (2)
865 shares its parent's mount namespace;
866 the mount namespace is preserved across an
867 .BR execve (2).
868 .PP
869 A process can obtain a private mount namespace if:
870 it was created using the
871 .BR clone (2)
872 .BR CLONE_NEWNS
873 flag,
874 in which case its new namespace is initialized to be a
875 .I copy
876 of the namespace of the process that called
877 .BR clone (2);
878 or it calls
879 .BR unshare (2)
880 with the
881 .BR CLONE_NEWNS
882 flag,
883 which causes the caller's mount namespace to obtain a private copy
884 of the namespace that it was previously sharing with other processes,
885 so that future mounts and unmounts by the caller are invisible
886 to other processes (except child processes that the caller
887 subsequently creates) and vice versa.
888 .PP
889 For further details on mount namespaces, see
890 .BR mount_namespaces (7).
891 .\"
892 .SS Parental relationship between mount points
893 Each mount point has a parent mount point.
894 The overall parental relationship of all mount points defines
895 the single directory hierarchy seen by the processes within a mount namespace.
896 .PP
897 The parent of a new mount point is defined when the mount point is created.
898 In the usual case,
899 the parent of a new mount is the mount point of the filesystem
900 containing the directory or file at which the new mount is attached.
901 In the case where a new mount is stacked on top of an existing mount,
902 the parent of the new mount is the previous mount that was stacked
903 at that location.
904 .PP
905 The parental relationship between mount points can be discovered via the
906 .I /proc/[pid]/mountinfo
907 file (see below).
908 .\"
909 .SS /proc/[pid]/mounts and /proc/[pid]/mountinfo
910 The Linux-specific
911 .I /proc/[pid]/mounts
912 file exposes the list of mount points in the mount
913 namespace of the process with the specified ID.
914 The
915 .I /proc/[pid]/mountinfo
916 file exposes even more information about mount points,
917 including the propagation type and mount ID information that makes it
918 possible to discover the parental relationship between mount points.
919 See
920 .BR proc (5)
921 and
922 .BR mount_namespaces (7)
923 for details of this file.
924 .SH SEE ALSO
925 .BR mountpoint (1),
926 .BR chroot (2),
927 .BR ioctl_iflags (2),
928 .BR pivot_root (2),
929 .BR umount (2),
930 .BR mount_namespaces (7),
931 .BR path_resolution (7),
932 .BR findmnt (8),
933 .BR lsblk (8),
934 .BR mount (8),
935 .BR umount (8)