console_codes.4: tfix
[man-pages.git] / man2 / mount.2
blobd8521880b444f56013e341152823c3ef768b5208
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 2021-03-22 "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 This argument may be specified as NULL, if there are no options.
83 .PP
84 A call to
85 .BR mount ()
86 performs one of a number of general types of operation,
87 depending on the bits specified in
88 .IR mountflags .
89 The choice of which operation to perform is determined by
90 testing the bits set in
91 .IR mountflags ,
92 with the tests being conducted in the order listed here:
93 .IP * 3
94 Remount an existing mount:
95 .IR mountflags
96 includes
97 .BR MS_REMOUNT .
98 .IP *
99 Create a bind mount:
100 .IR mountflags
101 includes
102 .BR MS_BIND .
103 .IP *
104 Change the propagation type of an existing mount:
105 .IR mountflags
106 includes one of
107 .BR MS_SHARED ,
108 .BR MS_PRIVATE ,
109 .BR MS_SLAVE ,
111 .BR MS_UNBINDABLE .
112 .IP *
113 Move an existing mount to a new location:
114 .IR mountflags
115 includes
116 .BR MS_MOVE .
117 .IP *
118 Create a new mount:
119 .IR mountflags
120 includes none of the above flags.
122 Each of these operations is detailed later in this page.
123 Further flags may be specified in
124 .IR mountflags
125 to modify the behavior of
126 .BR mount (),
127 as described below.
129 .SS Additional mount flags
130 The list below describes the additional flags that can be specified in
131 .IR mountflags .
132 Note that some operation types ignore some or all of these flags,
133 as described later in this page.
135 .\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented.
136 .\" commit 7a224228ed79d587ece2304869000aad1b8e97dd
137 .\" (This is a per-superblock flag)
140 .BR MS_DIRSYNC " (since Linux 2.5.19)"
141 Make directory changes on this filesystem synchronous.
142 (This property can be obtained for individual directories
143 or subtrees using
144 .BR chattr (1).)
146 .BR MS_LAZYTIME " (since Linux 4.0)"
147 .\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8
148 .\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6
149 .\" commit a26f49926da938f47561f386be56a83dd37a496d
150 Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
151 by maintaining these changes only in memory.
152 The on-disk timestamps are updated only when:
154 .IP (a) 4
155 the inode needs to be updated for some change unrelated to file timestamps;
156 .IP (b)
157 the application employs
158 .BR fsync (2),
159 .BR syncfs (2),
161 .BR sync (2);
162 .IP (c)
163 an undeleted inode is evicted from memory; or
164 .IP (d)
165 more than 24 hours have passed since the inode was written to disk.
168 This mount option significantly reduces writes
169 needed to update the inode's timestamps, especially mtime and atime.
170 However, in the event of a system crash, the atime and mtime fields
171 on disk might be out of date by up to 24 hours.
173 Examples of workloads where this option could be of significant benefit
174 include frequent random writes to preallocated files,
175 as well as cases where the
176 .B MS_STRICTATIME
177 mount option is also enabled.
178 (The advantage of combining
179 .BR MS_STRICTATIME
181 .BR MS_LAZYTIME
182 is that
183 .BR stat (2)
184 will return the correctly updated atime, but the atime updates
185 will be flushed to disk only in the cases listed above.)
187 .B MS_MANDLOCK
188 Permit mandatory locking on files in this filesystem.
189 (Mandatory locking must still be enabled on a per-file basis,
190 as described in
191 .BR fcntl (2).)
192 Since Linux 4.5,
193 .\" commit 95ace75414f312f9a7b93d873f386987b92a5301
194 this mount option requires the
195 .B CAP_SYS_ADMIN
196 capability and a kernel configured with the
197 .B CONFIG_MANDATORY_FILE_LOCKING
198 option.
200 .B MS_NOATIME
201 Do not update access times for (all types of) files on this filesystem.
203 .B MS_NODEV
204 Do not allow access to devices (special files) on this filesystem.
206 .B MS_NODIRATIME
207 Do not update access times for directories on this filesystem.
208 This flag provides a subset of the functionality provided by
209 .BR MS_NOATIME ;
210 that is,
211 .BR MS_NOATIME
212 implies
213 .BR MS_NODIRATIME .
215 .B MS_NOEXEC
216 Do not allow programs to be executed from this filesystem.
217 .\" (Possibly useful for a filesystem that contains non-Linux executables.
218 .\" Often used as a security feature, e.g., to make sure that restricted
219 .\" users cannot execute files uploaded using ftp or so.)
221 .B MS_NOSUID
222 Do not honor set-user-ID and set-group-ID bits or file capabilities
223 when executing programs from this filesystem.
224 .\" (This is a security feature to prevent users executing set-user-ID and
225 .\" set-group-ID programs from removable disk devices.)
227 .B MS_RDONLY
228 Mount filesystem read-only.
230 .BR MS_REC " (since Linux 2.4.11)"
231 Used in conjunction with
232 .BR MS_BIND
233 to create a recursive bind mount,
234 and in conjunction with the propagation type flags to recursively change
235 the propagation type of all of the mounts in a subtree.
236 See below for further details.
238 .BR MS_RELATIME " (since Linux 2.6.20)"
239 When a file on this filesystem is accessed,
240 update the file's last access time (atime) only if the current value
241 of atime is less than or equal to the file's last modification time (mtime)
242 or last status change time (ctime).
243 This option is useful for programs, such as
244 .BR mutt (1),
245 that need to know when a file has been read since it was last modified.
246 Since Linux 2.6.30, the kernel defaults to the behavior provided
247 by this flag (unless
248 .BR MS_NOATIME
249 was specified), and the
250 .B MS_STRICTATIME
251 flag is required to obtain traditional semantics.
252 In addition, since Linux 2.6.30,
253 the file's last access time is always updated if it
254 is more than 1 day old.
255 .\" Matthew Garrett notes in the patch that added this behavior
256 .\" that this lets utilities such as tmpreaper (which deletes
257 .\" files based on last access time) work correctly.
259 .BR MS_SILENT " (since Linux 2.6.17)"
260 Suppress the display of certain
261 .RI ( printk ())
262 warning messages in the kernel log.
263 This flag supersedes the misnamed and obsolete
264 .BR MS_VERBOSE
265 flag (available since Linux 2.4.12), which has the same meaning.
267 .BR MS_STRICTATIME " (since Linux 2.6.30)"
268 Always update the last access time (atime) when files on this
269 filesystem are accessed.
270 (This was the default behavior before Linux 2.6.30.)
271 Specifying this flag overrides the effect of setting the
272 .BR MS_NOATIME
274 .BR MS_RELATIME
275 flags.
277 .B MS_SYNCHRONOUS
278 Make writes on this filesystem synchronous (as though
280 .B O_SYNC
281 flag to
282 .BR open (2)
283 was specified for all file opens to this filesystem).
285 .BR MS_NOSYMFOLLOW " (since Linux 5.10)"
286 .\" dab741e0e02bd3c4f5e2e97be74b39df2523fc6e
287 Do not follow symbolic links when resolving paths.
288 Symbolic links can still be created,
290 .BR readlink (1),
291 .BR readlink (2),
292 .BR realpath (1),
294 .BR realpath (3)
295 all still work properly.
297 From Linux 2.4 onward, some of the above flags are
298 settable on a per-mount basis,
299 while others apply to the superblock of the mounted filesystem,
300 meaning that all mounts of the same filesystem share those flags.
301 (Previously, all of the flags were per-superblock.)
303 The per-mount-point flags are as follows:
304 .IP * 3
305 Since Linux 2.4:
306 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
307 flags are settable on a per-mount-point basis.
308 .IP *
309 Additionally, since Linux 2.6.16:
310 .B MS_NOATIME
312 .BR MS_NODIRATIME .
313 .IP *
314 Additionally, since Linux 2.6.20:
315 .BR MS_RELATIME .
317 The following flags are per-superblock:
318 .BR MS_DIRSYNC ,
319 .BR MS_LAZYTIME ,
320 .BR MS_MANDLOCK ,
321 .BR MS_SILENT ,
323 .BR MS_SYNCHRONOUS .
324 .\" And MS_I_VERSION?
325 The initial settings of these flags are determined on the first
326 mount of the filesystem, and will be shared by all subsequent mounts
327 of the same filesystem.
328 Subsequently, the settings of the flags can be changed
329 via a remount operation (see below).
330 Such changes will be visible via all mount points associated
331 with the filesystem.
333 Since Linux 2.6.16,
334 .B MS_RDONLY
335 can be set or cleared on a per-mount-point basis as well as on
336 the underlying filesystem superblock.
337 The mounted filesystem will be writable only if neither the filesystem
338 nor the mountpoint are flagged as read-only.
340 .SS Remounting an existing mount
341 An existing mount may be remounted by specifying
342 .B MS_REMOUNT
344 .IR mountflags .
345 This allows you to change the
346 .I mountflags
348 .I data
349 of an existing mount without having to unmount and remount the filesystem.
350 .I target
351 should be the same value specified in the initial
352 .BR mount ()
353 call.
356 .I source
358 .I filesystemtype
359 arguments are ignored.
362 .I mountflags
364 .I data
365 arguments should match the values used in the original
366 .BR mount ()
367 call, except for those parameters that are being deliberately changed.
369 The following
370 .I mountflags
371 can be changed:
372 .BR MS_LAZYTIME ,
373 .\" FIXME
374 .\" MS_LAZYTIME seems to be available only on a few filesystems,
375 .\" and on ext4, it seems (from experiment that this flag
376 .\" can only be enabled (but not disabled) on a remount.
377 .\" The following code in ext4_remount() (kernel 4.17) seems to
378 .\" confirm this:
380 .\"        if (*flags & SB_LAZYTIME)
381 .\"                sb->s_flags |= SB_LAZYTIME;
382 .BR MS_MANDLOCK ,
383 .BR MS_NOATIME ,
384 .BR MS_NODEV ,
385 .BR MS_NODIRATIME ,
386 .BR MS_NOEXEC ,
387 .BR MS_NOSUID ,
388 .BR MS_RELATIME ,
389 .BR MS_RDONLY ,
390 .BR MS_STRICTATIME
391 (whose effect is to clear the
392 .BR MS_NOATIME
394 .BR MS_RELATIME
395 flags),
397 .BR MS_SYNCHRONOUS .
398 Attempts to change the setting of the
399 .\" See the definition of MS_RMT_MASK in include/uapi/linux/fs.h,
400 .\" which excludes MS_DIRSYNC and MS_SILENT, although SB_DIRSYNC
401 .\" and SB_SILENT are split out as per-superblock flags in do_mount()
402 .\" (Linux 4.17 source code)
403 .BR MS_DIRSYNC
405 .BR MS_SILENT
406 flags during a remount are silently ignored.
407 Note that changes to per-superblock flags are visible via
408 all mount points of the associated filesystem
409 (because the per-superblock flags are shared by all mount points).
411 Since Linux 3.17,
412 .\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e
413 if none of
414 .BR MS_NOATIME ,
415 .BR MS_NODIRATIME ,
416 .BR MS_RELATIME ,
418 .BR MS_STRICTATIME
419 is specified in
420 .IR mountflags ,
421 then the remount operation preserves the existing values of these flags
422 (rather than defaulting to
423 .BR MS_RELATIME ).
425 Since Linux 2.6.26, the
426 .B MS_REMOUNT
427 flag can be used with
428 .B MS_BIND
429 to modify only the per-mount-point flags.
430 .\" See https://lwn.net/Articles/281157/
431 This is particularly useful for setting or clearing the "read-only"
432 flag on a mount point without changing the underlying filesystem.
433 Specifying
434 .IR mountflags
437 .in +4n
439 MS_REMOUNT | MS_BIND | MS_RDONLY
443 will make access through this mountpoint read-only, without affecting
444 other mount points.
446 .SS Creating a bind mount
448 .I mountflags
449 includes
450 .BR MS_BIND
451 (available since Linux 2.4),
452 .\" since 2.4.0-test9
453 then perform a bind mount.
454 A bind mount makes a file or a directory subtree visible at
455 another point within the single directory hierarchy.
456 Bind mounts may cross filesystem boundaries and span
457 .BR chroot (2)
458 jails.
461 .IR filesystemtype
463 .IR data
464 arguments are ignored.
466 The remaining bits (other than
467 .BR MS_REC ,
468 described below) in the
469 .I mountflags
470 argument are also ignored.
471 (The bind mount has the same mount options as
472 the underlying mount point.)
473 However, see the discussion of remounting above,
474 for a method of making an existing bind mount read-only.
476 By default, when a directory is bind mounted,
477 only that directory is mounted;
478 if there are any submounts under the directory tree,
479 they are not bind mounted.
480 If the
481 .BR MS_REC
482 flag is also specified, then a recursive bind mount operation is performed:
483 all submounts under the
484 .I source
485 subtree (other than unbindable mounts)
486 are also bind mounted at the corresponding location in the
487 .I target
488 subtree.
490 .SS Changing the propagation type of an existing mount
492 .IR mountflags
493 includes one of
494 .BR MS_SHARED ,
495 .BR MS_PRIVATE ,
496 .BR MS_SLAVE ,
498 .BR MS_UNBINDABLE
499 (all available since Linux 2.6.15),
500 then the propagation type of an existing mount is changed.
501 If more than one of these flags is specified, an error results.
503 The only other flags that can be specified while changing
504 the propagation type are
505 .BR MS_REC
506 (described below) and
507 .BR MS_SILENT
508 (which is ignored).
511 .IR source ,
512 .IR filesystemtype ,
514 .IR data
515 arguments are ignored.
517 The meanings of the propagation type flags are as follows:
519 .BR MS_SHARED
520 Make this mount point shared.
521 Mount and unmount events immediately under this mount point will propagate
522 to the other mount points that are members of this mount's peer group.
523 Propagation here means that the same mount or unmount will automatically
524 occur under all of the other mount points in the peer group.
525 Conversely, mount and unmount events that take place under
526 peer mount points will propagate to this mount point.
528 .BR MS_PRIVATE
529 Make this mount point private.
530 Mount and unmount events do not propagate into or out of this mount point.
532 .BR MS_SLAVE
533 If this is a shared mount point that is a member of a peer group
534 that contains other members, convert it to a slave mount.
535 If this is a shared mount point that is a member of a peer group
536 that contains no other members, convert it to a private mount.
537 Otherwise, the propagation type of the mount point is left unchanged.
539 When a mount point is a slave,
540 mount and unmount events propagate into this mount point from
541 the (master) shared peer group of which it was formerly a member.
542 Mount and unmount events under this mount point do not propagate to any peer.
544 A mount point can be the slave of another peer group
545 while at the same time sharing mount and unmount events
546 with a peer group of which it is a member.
548 .BR MS_UNBINDABLE
549 Make this mount unbindable.
550 This is like a private mount,
551 and in addition this mount can't be bind mounted.
552 When a recursive bind mount
553 .RB ( mount ()
554 with the
555 .BR MS_BIND
557 .BR MS_REC
558 flags) is performed on a directory subtree,
559 any unbindable mounts within the subtree are automatically pruned
560 (i.e., not replicated)
561 when replicating that subtree to produce the target subtree.
563 By default, changing the propagation type affects only the
564 .I target
565 mount point.
566 If the
567 .B MS_REC
568 flag is also specified in
569 .IR mountflags ,
570 then the propagation type of all mount points under
571 .IR target
572 is also changed.
574 For further details regarding mount propagation types
575 (including the default propagation type assigned to new mounts), see
576 .BR mount_namespaces (7).
578 .SS Moving a mount
580 .I mountflags
581 contains the flag
582 .BR MS_MOVE
583 (available since Linux 2.4.18),
584 then move a subtree:
585 .I source
586 specifies an existing mount point and
587 .I target
588 specifies the new location to which that mount point is to be relocated.
589 The move is atomic: at no point is the subtree unmounted.
591 The remaining bits in the
592 .IR mountflags
593 argument are ignored, as are the
594 .IR filesystemtype
596 .IR data
597 arguments.
599 .SS Creating a new mount point
600 If none of
601 .BR MS_REMOUNT ,
602 .BR MS_BIND ,
603 .BR MS_MOVE ,
604 .BR MS_SHARED ,
605 .BR MS_PRIVATE ,
606 .BR MS_SLAVE ,
608 .BR MS_UNBINDABLE
609 is specified in
610 .IR mountflags ,
611 then
612 .BR mount ()
613 performs its default action: creating a new mount point.
614 .IR source
615 specifies the source for the new mount point, and
616 .IR target
617 specifies the directory at which to create the mount point.
620 .I filesystemtype
622 .I data
623 arguments are employed, and further bits may be specified in
624 .IR mountflags
625 to modify the behavior of the call.
627 .SH RETURN VALUE
628 On success, zero is returned.
629 On error, \-1 is returned, and
630 .I errno
631 is set to indicate the error.
632 .SH ERRORS
633 The error values given below result from filesystem type independent
634 errors.
635 Each filesystem type may have its own special errors and its
636 own special behavior.
637 See the Linux kernel source code for details.
639 .B EACCES
640 A component of a path was not searchable.
641 (See also
642 .BR path_resolution (7).)
644 .B EACCES
645 Mounting a read-only filesystem was attempted without giving the
646 .B MS_RDONLY
647 flag.
649 The filesystem may be read-only for various reasons, including:
650 it resides on a read-only optical disk;
651 it is resides on a device with a physical switch that has been set to
652 mark the device read-only;
653 the filesystem implementation was compiled with read-only support;
654 or errors were detected when initially mounting the filesystem,
655 so that it was marked read-only
656 and can't be remounted as read-write (until the errors are fixed).
658 Some filesystems instead return the error
659 .BR EROFS
660 on an attempt to mount a read-only filesystem.
662 .B EACCES
663 The block device
664 .I source
665 is located on a filesystem mounted with the
666 .B MS_NODEV
667 option.
668 .\" mtk: Probably: write permission is required for MS_BIND, with
669 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
671 .B EBUSY
672 An attempt was made to stack a new mount directly on
673 top of an existing mount point that was created in this
674 mount namespace with the same
675 .I source
677 .IR target .
679 .B EBUSY
680 .I source
681 cannot be remounted read-only,
682 because it still holds files open for writing.
684 .B EFAULT
685 One of the pointer arguments points outside the user address space.
687 .B EINVAL
688 .I source
689 had an invalid superblock.
691 .B EINVAL
692 A remount operation
693 .RB ( MS_REMOUNT )
694 was attempted, but
695 .I source
696 was not already mounted on
697 .IR target .
699 .B EINVAL
700 A move operation
701 .RB ( MS_MOVE )
702 was attempted, but the mount tree under
703 .I source
704 includes unbindable mounts and
705 .I target
706 is a mount point that has propagation type
707 .BR MS_SHARED .
709 .B EINVAL
710 A move operation
711 .RB ( MS_MOVE )
712 was attempted, but the parent mount of
713 .I source
714 mount has propagation type
715 .BR MS_SHARED .
717 .B EINVAL
718 A move operation
719 .RB ( MS_MOVE )
720 was attempted, but
721 .I source
722 was not a mount point, or was \(aq/\(aq.
724 .B EINVAL
725 A bind operation
726 .RB ( MS_BIND )
727 was requested where
728 .I source
729 referred a mount namespace magic link (i.e., a
730 .I /proc/[pid]/ns/mnt
731 magic link or a bind mount to such a link)
732 and the propagation type of the parent mount of
733 .I target
735 .BR MS_SHARED ,
736 .\" See commit 8823c079ba7136dc1948d6f6dcb5f8022bde438e
737 but propagation of the requested bind mount could lead to a circular
738 dependency that might prevent the mount namespace from ever being freed.
740 .B EINVAL
741 .I mountflags
742 includes more than one of
743 .BR MS_SHARED ,
744 .BR MS_PRIVATE ,
745 .BR MS_SLAVE ,
747 .BR MS_UNBINDABLE .
749 .B EINVAL
750 .I mountflags
751 includes
752 .BR MS_SHARED ,
753 .BR MS_PRIVATE ,
754 .BR MS_SLAVE ,
756 .BR MS_UNBINDABLE
757 and also includes a flag other than
758 .BR MS_REC
760 .BR MS_SILENT .
762 .BR EINVAL
763 An attempt was made to bind mount an unbindable mount.
765 .BR EINVAL
766 In an unprivileged mount namespace
767 (i.e., a mount namespace owned by a user namespace
768 that was created by an unprivileged user),
769 a bind mount operation
770 .RB ( MS_BIND )
771 was attempted without specifying
772 .RB ( MS_REC ),
773 which would have revealed the filesystem tree underneath one of
774 the submounts of the directory being bound.
776 .B ELOOP
777 Too many links encountered during pathname resolution.
779 .B ELOOP
780 A move operation was attempted, and
781 .I target
782 is a descendant of
783 .IR source .
785 .B EMFILE
786 (In case no block device is required:)
787 Table of dummy devices is full.
789 .B ENAMETOOLONG
790 A pathname was longer than
791 .BR MAXPATHLEN .
793 .B ENODEV
794 .I filesystemtype
795 not configured in the kernel.
797 .B ENOENT
798 A pathname was empty or had a nonexistent component.
800 .B ENOMEM
801 The kernel could not allocate a free page to copy filenames or data into.
803 .B ENOTBLK
804 .I source
805 is not a block device (and a device was required).
807 .B ENOTDIR
808 .IR target ,
809 or a prefix of
810 .IR source ,
811 is not a directory.
813 .B ENXIO
814 The major number of the block device
815 .I source
816 is out of range.
818 .B EPERM
819 The caller does not have the required privileges.
821 .B EROFS
822 Mounting a read-only filesystem was attempted without giving the
823 .B MS_RDONLY
824 flag.
826 .BR EACCES ,
827 above.
828 .SH VERSIONS
829 The definitions of
830 .BR MS_DIRSYNC ,
831 .BR MS_MOVE ,
832 .BR MS_PRIVATE ,
833 .BR MS_REC ,
834 .BR MS_RELATIME ,
835 .BR MS_SHARED ,
836 .BR MS_SLAVE ,
837 .BR MS_STRICTATIME ,
839 .BR MS_UNBINDABLE
840 were added to glibc headers in version 2.12.
842 .SH CONFORMING TO
843 This function is Linux-specific and should not be used in
844 programs intended to be portable.
845 .SH NOTES
846 Since Linux 2.4 a single filesystem can be mounted at
847 multiple mount points, and multiple mounts can be stacked
848 on the same mount point.
849 .\" Multiple mounts on same mount point: since 2.3.99pre7.
852 .I mountflags
853 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
854 in the top 16 bits.
855 (All of the other flags discussed in DESCRIPTION
856 occupy the low order 16 bits of
857 .IR mountflags .)
858 Specifying
859 .BR MS_MGC_VAL
860 was required in kernel versions prior to 2.4,
861 but since Linux 2.4 is no longer required and is ignored if specified.
863 The original
864 .B MS_SYNC
865 flag was renamed
866 .B MS_SYNCHRONOUS
867 in 1.1.69
868 when a different
869 .B MS_SYNC
870 was added to \fI<mman.h>\fP.
872 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
873 on a filesystem mounted with
874 .B MS_NOSUID
875 would fail with
876 .BR EPERM .
877 Since Linux 2.4 the set-user-ID and set-group-ID bits are
878 just silently ignored in this case.
879 .\" The change is in patch-2.4.0-prerelease.
881 .SS Mount namespaces
882 Starting with kernel 2.4.19, Linux provides mount namespaces.
883 A mount namespace is the set of filesystem mounts that
884 are visible to a process.
885 Mount namespaces can be (and usually are)
886 shared between multiple processes,
887 and changes to the namespace (i.e., mounts and unmounts) by one process
888 are visible to all other processes sharing the same namespace.
889 (The pre-2.4.19 Linux situation can be considered as one in which
890 a single namespace was shared by every process on the system.)
892 A child process created by
893 .BR fork (2)
894 shares its parent's mount namespace;
895 the mount namespace is preserved across an
896 .BR execve (2).
898 A process can obtain a private mount namespace if:
899 it was created using the
900 .BR clone (2)
901 .BR CLONE_NEWNS
902 flag,
903 in which case its new namespace is initialized to be a
904 .I copy
905 of the namespace of the process that called
906 .BR clone (2);
907 or it calls
908 .BR unshare (2)
909 with the
910 .BR CLONE_NEWNS
911 flag,
912 which causes the caller's mount namespace to obtain a private copy
913 of the namespace that it was previously sharing with other processes,
914 so that future mounts and unmounts by the caller are invisible
915 to other processes (except child processes that the caller
916 subsequently creates) and vice versa.
918 For further details on mount namespaces, see
919 .BR mount_namespaces (7).
921 .SS Parental relationship between mount points
922 Each mount point has a parent mount point.
923 The overall parental relationship of all mount points defines
924 the single directory hierarchy seen by the processes within a mount namespace.
926 The parent of a new mount point is defined when the mount point is created.
927 In the usual case,
928 the parent of a new mount is the mount point of the filesystem
929 containing the directory or file at which the new mount is attached.
930 In the case where a new mount is stacked on top of an existing mount,
931 the parent of the new mount is the previous mount that was stacked
932 at that location.
934 The parental relationship between mount points can be discovered via the
935 .I /proc/[pid]/mountinfo
936 file (see below).
938 .SS /proc/[pid]/mounts and /proc/[pid]/mountinfo
939 The Linux-specific
940 .I /proc/[pid]/mounts
941 file exposes the list of mount points in the mount
942 namespace of the process with the specified ID.
944 .I /proc/[pid]/mountinfo
945 file exposes even more information about mount points,
946 including the propagation type and mount ID information that makes it
947 possible to discover the parental relationship between mount points.
949 .BR proc (5)
951 .BR mount_namespaces (7)
952 for details of this file.
953 .SH SEE ALSO
954 .BR mountpoint (1),
955 .BR chroot (2),
956 .BR ioctl_iflags (2),
957 .BR pivot_root (2),
958 .BR umount (2),
959 .BR mount_namespaces (7),
960 .BR path_resolution (7),
961 .BR findmnt (8),
962 .BR lsblk (8),
963 .BR mount (8),
964 .BR umount (8)