]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/mount.2
mount.2: srcfix: update FIXME
[thirdparty/man-pages.git] / man2 / mount.2
CommitLineData
fea681da 1.\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
6883b3e7 2.\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
eac1e050 3.\" and Copyright (C) 2002, 2005, 2016 Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 4.\"
93015253 5.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 14.\"
fea681da
MK
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.
c13182ef 22.\"
fea681da
MK
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 25.\" %%%LICENSE_END
fea681da
MK
26.\"
27.\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
c11b1abf 28.\" Modified 2001-10-13 by Michael Kerrisk <mtk.manpages@gmail.com>
d9bfdb9c 29.\" Added note on historical behavior of MS_NOSUID
c11b1abf 30.\" Modified 2002-05-16 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
31.\" Extensive changes and additions
32.\" Modified 2002-05-27 by aeb
c11b1abf 33.\" Modified 2002-06-11 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 34.\" Enhanced descriptions of MS_MOVE, MS_BIND, and MS_REMOUNT
c11b1abf 35.\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
8df37e4d 36.\" 2005-05-18, mtk, Added MNT_EXPIRE, plus a few other tidy-ups.
0a4d78bb
MK
37.\" 2008-10-06, mtk: move umount*() material into separate umount.2 page.
38.\" 2008-10-06, mtk: Add discussion of namespaces.
fea681da 39.\"
8538a62b 40.TH MOUNT 2 2018-02-02 "Linux" "Linux Programmer's Manual"
fea681da 41.SH NAME
9ee4a2b6 42mount \- mount filesystem
fea681da 43.SH SYNOPSIS
7998dde2 44.nf
fea681da 45.B "#include <sys/mount.h>"
68e4db0a 46.PP
fea681da 47.BI "int mount(const char *" source ", const char *" target ,
7998dde2
MK
48.BI " const char *" filesystemtype ", unsigned long " mountflags ,
49.BI " const void *" data );
7998dde2 50.fi
fea681da 51.SH DESCRIPTION
e511ffb6 52.BR mount ()
9ee4a2b6 53attaches the filesystem specified by
fea681da 54.I source
751de899
MK
55(which is often a pathname referring to a device,
56but can also be the pathname of a directory or file,
57or a dummy string) to the location (a directory or file)
58specified by the pathname in
fea681da 59.IR target .
547ee319 60.PP
fea681da
MK
61Appropriate privilege (Linux: the
62.B CAP_SYS_ADMIN
9ee4a2b6 63capability) is required to mount filesystems.
547ee319 64.PP
fea681da 65Values for the
0daa9e92 66.I filesystemtype
fea681da
MK
67argument supported by the kernel are listed in
68.I /proc/filesystems
9792cd16
MK
69(e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse",
70"tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs", "iso9660").
fea681da
MK
71Further types may become available when the appropriate modules
72are loaded.
547ee319 73.PP
b3ae9c7d
MK
74The
75.I data
76argument is interpreted by the different filesystems.
77Typically it is a string of comma-separated options
78understood by this filesystem.
79See
80.BR mount (8)
81for details of the options available for each filesystem type.
547ee319 82.PP
f429fadc
MK
83A call to
84.BR mount ()
c3a7b4e9 85performs one of a number of general types of operation,
f429fadc
MK
86depending on the bits specified in
87.IR mountflags .
c3a7b4e9
MK
88The choice of which operation to perform is determined by
89testing the bits set in
f429fadc
MK
90.IR mountflags ,
91with the tests being conducted in the order listed here:
92.IP * 3
93Remount an existing mount:
94.IR mountflags
95includes
96.BR MS_REMOUNT .
97.IP *
98Create a bind mount:
99.IR mountflags
100includes
101.BR MS_BIND .
102.IP *
103Change the propagation type of an existing mount:
104.IR mountflags
105includes one of
106.BR MS_SHARED ,
107.BR MS_PRIVATE ,
108.BR MS_SLAVE ,
109or
110.BR MS_UNBINDABLE .
111.IP *
112Move an existing mount to a new location:
113.IR mountflags
114includes
115.BR MS_MOVE .
116.IP *
117Create a new mount:
118.IR mountflags
119includes none of the above flags.
120.PP
121Each of these operations is detailed later in this page.
122Further flags may be specified in
123.IR mountflags
124to modify the behavior of
125.BR mount (),
126as described below.
2835e6c5 127.\"
f429fadc
MK
128.SS Additional mount flags
129The list below describes the additional flags that can be specified in
130.IR mountflags .
131Note that some operation types ignore some or all of these flags,
132as described later in this page.
2835e6c5 133.\"
bea08fec 134.\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented.
fa4c100d
MK
135.\" commit 7a224228ed79d587ece2304869000aad1b8e97dd
136.\" (This is a per-superblock flag)
21d995a8 137.\"
fea681da 138.TP
8df37e4d 139.BR MS_DIRSYNC " (since Linux 2.5.19)"
9ee4a2b6 140Make directory changes on this filesystem synchronous.
fea681da
MK
141(This property can be obtained for individual directories
142or subtrees using
49ec013c 143.BR chattr (1).)
fea681da 144.TP
9b249562 145.BR MS_LAZYTIME " (since Linux 4.0)"
42a8e396
MK
146.\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8
147.\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6
148.\" commit a26f49926da938f47561f386be56a83dd37a496d
149Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
150by maintaining these changes only in memory.
151The on-disk timestamps are updated only when:
152.RS
153.IP (a) 5
154the inode needs to be updated for some change unrelated to file timestamps;
155.IP (b)
156the application employs
157.BR fsync (2),
158.BR syncfs (2),
159or
160.BR sync (2);
161.IP (c)
162an undeleted inode is evicted from memory; or
163.IP (d)
164more than 24 hours have passed since the inode was written to disk.
165.RE
166.IP
5eab76af 167This mount option significantly reduces writes
9cdabfa6
MK
168needed to update the inode's timestamps, especially mtime and atime.
169However, in the event of a system crash, the atime and mtime fields
170on disk might be out of date by up to 24 hours.
054ea65e 171.IP
9cdabfa6
MK
172Examples of workloads where this option could be of significant benefit
173include frequent random writes to preallocated files,
174as well as cases where the
175.B MS_STRICTATIME
176mount option is also enabled.
cdd14e51
MK
177(The advantage of combining
178.BR MS_STRICTATIME
179and
180.BR MS_LAZYTIME
9cdabfa6
MK
181is that
182.BR stat (2)
183will return the correctly updated atime, but the atime updates
5eab76af 184will be flushed to disk only in the cases listed above.)
42a8e396 185.TP
fea681da 186.B MS_MANDLOCK
9ee4a2b6 187Permit mandatory locking on files in this filesystem.
fea681da
MK
188(Mandatory locking must still be enabled on a per-file basis,
189as described in
190.BR fcntl (2).)
afa0b44d
MK
191Since Linux 4.5,
192.\" commit 95ace75414f312f9a7b93d873f386987b92a5301
193this mount option requires the
194.B CAP_SYS_ADMIN
41976bc5
MK
195capability and a kernel configured with the
196.B CONFIG_MANDATORY_FILE_LOCKING
197option.
fea681da 198.TP
fea681da 199.B MS_NOATIME
9ee4a2b6 200Do not update access times for (all types of) files on this filesystem.
fea681da
MK
201.TP
202.B MS_NODEV
9ee4a2b6 203Do not allow access to devices (special files) on this filesystem.
fea681da
MK
204.TP
205.B MS_NODIRATIME
9ee4a2b6 206Do not update access times for directories on this filesystem.
882a9435
MK
207This flag provides a subset of the functionality provided by
208.BR MS_NOATIME ;
209that is,
210.BR MS_NOATIME
211implies
212.BR MS_NODIRATIME .
fea681da
MK
213.TP
214.B MS_NOEXEC
9ee4a2b6
MK
215Do not allow programs to be executed from this filesystem.
216.\" (Possibly useful for a filesystem that contains non-Linux executables.
75b94dc3 217.\" Often used as a security feature, e.g., to make sure that restricted
fea681da
MK
218.\" users cannot execute files uploaded using ftp or so.)
219.TP
220.B MS_NOSUID
4be9e801
MK
221Do not honor set-user-ID and set-group-ID bits or file capabilities
222when executing programs from this filesystem.
880f5b4b
MK
223.\" (This is a security feature to prevent users executing set-user-ID and
224.\" set-group-ID programs from removable disk devices.)
fea681da
MK
225.TP
226.B MS_RDONLY
9ee4a2b6 227Mount filesystem read-only.
eac1e050
MK
228.TP
229.BR MS_REC " (since Linux 2.4.11)"
230Used in conjunction with
231.BR MS_BIND
232to create a recursive bind mount,
233and in conjunction with the propagation type flags to recursively change
234the propagation type of all of the mounts in a subtree.
235See below for further details.
c13182ef 236.TP
31c1f2b0 237.BR MS_RELATIME " (since Linux 2.6.20)"
9ee4a2b6 238When a file on this filesystem is accessed,
33a0ccb2 239update the file's last access time (atime) only if the current value
7c40de08 240of atime is less than or equal to the file's last modification time (mtime)
926b6e37
MK
241or last status change time (ctime).
242This option is useful for programs, such as
243.BR mutt (1),
244that need to know when a file has been read since it was last modified.
02a4e226
MK
245Since Linux 2.6.30, the kernel defaults to the behavior provided
246by this flag (unless
247.BR MS_NOATIME
248was specified), and the
249.B MS_STRICTATIME
250flag is required to obtain traditional semantics.
251In addition, since Linux 2.6.30,
252the file's last access time is always updated if it
253is 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
5116355c 256.\" files based on last access time) work correctly.
fea681da 257.TP
f429fadc
MK
258.BR MS_SILENT " (since Linux 2.6.17)"
259Suppress the display of certain
260.RI ( printk ())
261warning messages in the kernel log.
262This flag supersedes the misnamed and obsolete
263.BR MS_VERBOSE
264flag (available since Linux 2.4.12), which has the same meaning.
265.TP
266.BR MS_STRICTATIME " (since Linux 2.6.30)"
267Always update the last access time (atime) when files on this
268filesystem are accessed.
269(This was the default behavior before Linux 2.6.30.)
270Specifying this flag overrides the effect of setting the
271.BR MS_NOATIME
272and
273.BR MS_RELATIME
274flags.
275.TP
276.B MS_SYNCHRONOUS
277Make writes on this filesystem synchronous (as though
278the
279.B O_SYNC
280flag to
281.BR open (2)
282was specified for all file opens to this filesystem).
283.PP
284From Linux 2.4 onward, the
285.BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
286flags are settable on a per-mount-point basis.
287From kernel 2.6.16 onward,
288.B MS_NOATIME
289and
290.B MS_NODIRATIME
291are also settable on a per-mount-point basis.
292The
293.B MS_RELATIME
294flag is also settable on a per-mount-point basis.
c84a8779
N
295Since Linux 2.6.16,
296.B MS_RDONLY
297can be set or cleared on a per-mount-point basis as well as on
0e1a971b 298the underlying filesystem.
9edbd686
MK
299The mounted filesystem will be writable only if neither the filesystem
300nor the mountpoint are flagged as read-only.
f429fadc
MK
301.\"
302.SS Remounting an existing mount
303An existing mount may be remounted by specifying
fea681da 304.B MS_REMOUNT
f429fadc
MK
305in
306.IR mountflags .
599e5da7 307This allows you to change the
fea681da
MK
308.I mountflags
309and
310.I data
9ee4a2b6 311of an existing mount without having to unmount and remount the filesystem.
fea681da 312.I target
44535dd2 313should be the same value specified in the initial
fea681da 314.BR mount ()
74b46b5f 315call.
547ee319 316.PP
74b46b5f 317The
44535dd2
MK
318.I source
319and
fea681da 320.I filesystemtype
74b46b5f 321arguments are ignored.
547ee319 322.PP
69b6b231
EB
323The
324.I mountflags
325and
326.I data
327arguments should match the values used in the original
328.BR mount ()
329call, except for those parameters that are being deliberately changed.
c84a8779
N
330Another exception is that
331.B MS_BIND
a4222367 332has a different meaning for remount, and it should be included only if
c84a8779 333explicitly desired.
a4222367 334.PP
178b977b 335The following
c13182ef 336.I mountflags
178b977b 337can be changed:
9c2678e6 338.BR MS_LAZYTIME ,
495a1a89
MK
339.\" FIXME
340.\" MS_LAZYTIME seems to be available only on a few filesystems,
341.\" and on ext4, it seems (from experiment that this flag
342.\" can only be enabled (but not disabled) on a remount.
343.\" The following code in ext4_remount() (kernel 4.17) seems to
344.\" confirm this:
345.\"
346.\" if (*flags & SB_LAZYTIME)
347.\" sb->s_flags |= SB_LAZYTIME;
014b17c6
MK
348.BR MS_MANDLOCK ,
349.BR MS_NOATIME ,
178b977b 350.BR MS_NODEV ,
014b17c6
MK
351.BR MS_NODIRATIME ,
352.BR MS_NOEXEC ,
353.BR MS_NOSUID ,
9c2678e6 354.BR MS_RELATIME ,
014b17c6 355.BR MS_RDONLY ,
16008a41 356and
014b17c6 357.BR MS_SYNCHRONOUS .
d8b67bc9
MK
358Attempts to change the setting of the
359.\" See the definition of MS_RMT_MASK in include/uapi/linux/fs.h
360.BR MS_DIRSYNC
361flag during a remount are silently ignored.
547ee319 362.PP
49f68546
MK
363Since Linux 3.17,
364.\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e
365if none of
366.BR MS_NOATIME ,
367.BR MS_NODIRATIME ,
368.BR MS_RELATIME ,
369or
370.BR MS_STRICTATIME
371is specified in
372.IR mountflags ,
373then the remount operation preserves the existing values of these flags
374(rather than defaulting to
375.BR MS_RELATIME ).
a4222367 376.PP
5ea1abf8
MK
377Since Linux 2.6.26, the
378.B MS_RMOUNT
379flag can be used with
c84a8779 380.B MS_BIND
a4222367 381to modify only the per-mount-point flags.
f5da58a8 382.\" See https://lwn.net/Articles/281157/
c84a8779
N
383This is particularly useful for setting or clearing the "read-only"
384flag on a mount point without changing the underlying filesystem.
385Specifying
f5da58a8
MK
386.IR mountflags
387as:
a4222367 388.PP
e56ab30d
MK
389.in +4n
390.EX
391MS_REMOUNT | MS_BIND | MS_RDONLY
392.EE
393.in
a4222367 394.PP
c84a8779
N
395will make access through this mountpoint read-only, without affecting
396other mount points.
f429fadc
MK
397.\"
398.SS Creating a bind mount
399If
400.I mountflags
401includes
402.BR MS_BIND
403(available since Linux 2.4),
404.\" since 2.4.0-test9
405then perform a bind mount.
406A bind mount makes a file or a directory subtree visible at
407another point within the single directory hierarchy.
408Bind mounts may cross filesystem boundaries and span
409.BR chroot (2)
410jails.
547ee319 411.PP
f429fadc
MK
412The
413.IR filesystemtype
02a4e226 414and
f429fadc
MK
415.IR data
416arguments are ignored.
547ee319 417.PP
f429fadc
MK
418The remaining bits in the
419.I mountflags
420argument are also ignored, with the exception of
421.BR MS_REC .
422(The bind mount has the same mount options as
423the underlying mount point.)
424However, see the discussion of remounting above,
425for a method of making an existing bind mount read-only.
547ee319 426.PP
eac1e050
MK
427By default, when a directory is bind mounted,
428only that directory is mounted;
429if there are any submounts under the directory tree,
430they are not bind mounted.
431If the
432.BR MS_REC
433flag is also specified, then a recursive bind mount operation is performed:
434all submounts under the
435.I source
436subtree (other than unbindable mounts)
437are also bind mounted at the corresponding location in the
438.I target
439subtree.
f429fadc
MK
440.\"
441.SS Changing the propagation type of an existing mount
c8e5f558
MK
442If
443.IR mountflags
444includes one of
445.BR MS_SHARED ,
446.BR MS_PRIVATE ,
447.BR MS_SLAVE ,
448or
449.BR MS_UNBINDABLE
450(all available since Linux 2.6.15),
451then the propagation type of an existing mount is changed.
452If more than one of these flags is specified, an error results.
547ee319 453.PP
c8e5f558
MK
454The only flags that can be used with changing the propagation type are
455.BR MS_REC
456and
457.BR MS_SILENT .
547ee319 458.PP
c8e5f558
MK
459The
460.IR source ,
461.IR filesystemtype ,
462and
463.IR data
464arguments are ignored.
547ee319 465.PP
c8e5f558
MK
466The meanings of the propagation type flags are as follows:
467.TP
468.BR MS_SHARED
469Make this mount point shared.
470Mount and unmount events immediately under this mount point will propagate
471to the other mount points that are members of this mount's peer group.
472Propagation here means that the same mount or unmount will automatically
473occur under all of the other mount points in the peer group.
474Conversely, mount and unmount events that take place under
475peer mount points will propagate to this mount point.
476.TP
477.BR MS_PRIVATE
478Make this mount point private.
479Mount and unmount events do not propagate into or out of this mount point.
c8e5f558
MK
480.TP
481.BR MS_SLAVE
482If this is a shared mount point that is a member of a peer group
483that contains other members, convert it to a slave mount.
484If this is a shared mount point that is a member of a peer group
485that contains no other members, convert it to a private mount.
486Otherwise, the propagation type of the mount point is left unchanged.
054ea65e 487.IP
c8e5f558
MK
488When a mount point is a slave,
489mount and unmount events propagate into this mount point from
490the (master) shared peer group of which it was formerly a member.
491Mount and unmount events under this mount point do not propagate to any peer.
054ea65e 492.IP
c8e5f558
MK
493A mount point can be the slave of another peer group
494while at the same time sharing mount and unmount events
495with a peer group of which it is a member.
496.TP
497.BR MS_UNBINDABLE
498Make this mount unbindable.
499This is like a private mount,
500and in addition this mount can't be bind mounted.
501When a recursive bind mount
bf7bc8b8 502.RB ( mount ()
c8e5f558
MK
503with the
504.BR MS_BIND
505and
506.BR MS_REC
507flags) is performed on a directory subtree,
508any bind mounts within the subtree are automatically pruned
509(i.e., not replicated)
510when replicating that subtree to produce the target subtree.
eac1e050
MK
511.PP
512By default, changing the propagation type affects only the
513.I target
514mount point.
515If the
516.B MS_REC
517flag is also specified in
518.IR mountflags ,
519then the propagation type of all mount points under
520.IR target
521is also changed.
547ee319 522.PP
472bbe3b
MK
523For further details regarding mount propagation types
524(including the default propagation type assigned to new mounts), see
b7b79845 525.BR mount_namespaces (7).
f429fadc
MK
526.\"
527.SS Moving a mount
528If
529.I mountflags
530contains the flag
4a19136b
MK
531.BR MS_MOVE
532(available since Linux 2.4.18),
f429fadc
MK
533then move a subtree:
534.I source
535specifies an existing mount point and
536.I target
537specifies the new location to which that mount point is to be relocated.
538The move is atomic: at no point is the subtree unmounted.
547ee319 539.PP
f429fadc
MK
540The remaining bits in the
541.IR mountflags
542argument are ignored, as are the
543.IR filesystemtype
564d9941 544and
f429fadc
MK
545.IR data
546arguments.
547.\"
548.SS Creating a new mount point
549If none of
550.BR MS_REMOUNT ,
551.BR MS_BIND ,
552.BR MS_MOVE ,
553.BR MS_SHARED ,
554.BR MS_PRIVATE ,
555.BR MS_SLAVE ,
556or
557.BR MS_UNBINDABLE
558is specified in
559.IR mountflags ,
560then
561.BR mount ()
562performs its default action: creating a new mount point.
563.IR source
564specifies the source for the new mount point, and
565.IR target
566specifies the directory at which to create the mount point.
547ee319 567.PP
c13182ef 568The
f429fadc
MK
569.I filesystemtype
570and
571.I data
572arguments are employed, and further bits may be specified in
573.IR mountflags
574to modify the behavior of the call.
575.\"
d282bb24 576.SH RETURN VALUE
c13182ef
MK
577On success, zero is returned.
578On error, \-1 is returned, and
fea681da
MK
579.I errno
580is set appropriately.
581.SH ERRORS
582The error values given below result from filesystem type independent
c13182ef 583errors.
9ee4a2b6 584Each filesystem type may have its own special errors and its
c13182ef 585own special behavior.
66a9882e 586See the Linux kernel source code for details.
fea681da
MK
587.TP
588.B EACCES
c13182ef
MK
589A component of a path was not searchable.
590(See also
ad7cc990 591.BR path_resolution (7).)
9e1ae4f8
MK
592.TP
593.B EACCES
594Mounting a read-only filesystem was attempted without giving the
c13182ef 595.B MS_RDONLY
8df37e4d 596flag.
9e1ae4f8
MK
597.TP
598.B EACCES
599The block device
fea681da 600.I source
9ee4a2b6 601is located on a filesystem mounted with the
8df37e4d
MK
602.B MS_NODEV
603option.
fea681da
MK
604.\" mtk: Probably: write permission is required for MS_BIND, with
605.\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
606.TP
607.B EBUSY
050f3494
MK
608An attempt was made to stack a new mount directly on
609top of an existing mount point that was created in this
610mount namespace with the same
611.I source
612and
613.IR target .
614.TP
615.B EBUSY
9e1ae4f8
MK
616.I source
617cannot be remounted read-only,
fea681da 618because it still holds files open for writing.
9e1ae4f8 619.TP
fea681da
MK
620.B EFAULT
621One of the pointer arguments points outside the user address space.
622.TP
623.B EINVAL
624.I source
625had an invalid superblock.
9e1ae4f8
MK
626.TP
627.B EINVAL
628A remount operation
8df37e4d
MK
629.RB ( MS_REMOUNT )
630was attempted, but
fea681da
MK
631.I source
632was not already mounted on
633.IR target .
9e1ae4f8
MK
634.TP
635.B EINVAL
636A move operation
8df37e4d
MK
637.RB ( MS_MOVE )
638was attempted, but
fea681da 639.I source
f81fb444 640was not a mount point, or was \(aq/\(aq.
fea681da 641.TP
c8e5f558
MK
642.B EINVAL
643.I mountflags
644includes more than one of
645.BR MS_SHARED ,
646.BR MS_PRIVATE ,
647.BR MS_SLAVE ,
648or
649.BR MS_UNBINDABLE .
650.TP
651.B EINVAL
652.I mountflags
653includes
654.BR MS_SHARED ,
655.BR MS_PRIVATE ,
656.BR MS_SLAVE ,
657or
658.BR MS_UNBINDABLE
659and also includes a flag other than
660.BR MS_REC
661or
662.BR MS_SILENT .
663.TP
664.BR EINVAL
665An attempt was made to bind mount an unbindable mount.
666.TP
360d7455 667.BR EINVAL
f54c67bf
MK
668In an unprivileged mount namespace
669(i.e., a mount namespace owned by a user namespace
670that was created by an unprivileged user),
671a bind mount operation
360d7455
KF
672.RB ( MS_BIND )
673was attempted without specifying
674.RB ( MS_REC ),
3484e69f 675which would have revealed the filesystem tree underneath one of
360d7455
KF
676the submounts of the directory being bound.
677.TP
fea681da 678.B ELOOP
9b9b4a81 679Too many links encountered during pathname resolution.
9e1ae4f8
MK
680.TP
681.B ELOOP
682A move operation was attempted, and
fea681da
MK
683.I target
684is a descendant of
685.IR source .
686.TP
687.B EMFILE
688(In case no block device is required:)
689Table of dummy devices is full.
690.TP
691.B ENAMETOOLONG
682edefb
MK
692A pathname was longer than
693.BR MAXPATHLEN .
fea681da
MK
694.TP
695.B ENODEV
a90440ba 696.I filesystemtype
fea681da
MK
697not configured in the kernel.
698.TP
699.B ENOENT
700A pathname was empty or had a nonexistent component.
701.TP
702.B ENOMEM
703The kernel could not allocate a free page to copy filenames or data into.
704.TP
705.B ENOTBLK
706.I source
707is not a block device (and a device was required).
708.TP
709.B ENOTDIR
5614f733
MK
710.IR target ,
711or a prefix of
712.IR source ,
713is not a directory.
fea681da
MK
714.TP
715.B ENXIO
716The major number of the block device
717.I source
718is out of range.
719.TP
720.B EPERM
721The caller does not have the required privileges.
9326e678
MK
722.SH VERSIONS
723The definitions of
724.BR MS_DIRSYNC ,
725.BR MS_MOVE ,
f429fadc 726.BR MS_PRIVATE ,
9326e678
MK
727.BR MS_REC ,
728.BR MS_RELATIME ,
f429fadc 729.BR MS_SHARED ,
67215694 730.BR MS_SLAVE ,
a6bfc757 731.BR MS_STRICTATIME ,
f429fadc
MK
732and
733.BR MS_UNBINDABLE
33a0ccb2 734were added to glibc headers in version 2.12.
f429fadc 735.\"
d282bb24 736.SH CONFORMING TO
5614f733 737This function is Linux-specific and should not be used in
fea681da 738programs intended to be portable.
889829be 739.SH NOTES
f54e02b4
MK
740Since Linux 2.4 a single filesystem can be mounted at
741multiple mount points, and multiple mounts can be stacked
742on the same mount point.
743.\" Multiple mounts on same mount point: since 2.3.99pre7.
547ee319 744.PP
52f00c05
MK
745The
746.I mountflags
747argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
748in the top 16 bits.
749(All of the other flags discussed in DESCRIPTION
750occupy the low order 16 bits of
751.IR mountflags .)
752Specifying
753.BR MS_MGC_VAL
754was required in kernel versions prior to 2.4,
755but since Linux 2.4 is no longer required and is ignored if specified.
547ee319 756.PP
fea681da 757The original
0daa9e92 758.B MS_SYNC
682edefb 759flag was renamed
0daa9e92 760.B MS_SYNCHRONOUS
682edefb
MK
761in 1.1.69
762when a different
0daa9e92 763.B MS_SYNC
682edefb 764was added to \fI<mman.h>\fP.
dd3568a1 765.PP
880f5b4b 766Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
9ee4a2b6 767on a filesystem mounted with
fea681da
MK
768.B MS_NOSUID
769would fail with
770.BR EPERM .
c13182ef 771Since Linux 2.4 the set-user-ID and set-group-ID bits are
880f5b4b 772just silently ignored in this case.
fea681da 773.\" The change is in patch-2.4.0-prerelease.
f54e02b4 774.\"
29a68c5b 775.SS Per-process namespaces
4df2eb09 776Starting with kernel 2.4.19, Linux provides
732e54dd 777per-process mount namespaces.
9ee4a2b6 778A mount namespace is the set of filesystem mounts that
4df2eb09
MK
779are visible to a process.
780Mount-point namespaces can be (and usually are)
781shared between multiple processes,
0a4d78bb
MK
782and changes to the namespace (i.e., mounts and unmounts) by one process
783are visible to all other processes sharing the same namespace.