]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/mount.2
mount.2: List a few other file systems that we may see in /proc/filesystems
[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 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
5 .\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
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@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 .\"
38 .TH MOUNT 2 2008-10-06 "Linux" "Linux Programmer's Manual"
39 .SH NAME
40 mount \- mount file system
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 .fi
49 .SH DESCRIPTION
50 .BR mount ()
51 attaches the file system specified by
52 .I source
53 (which is often a device name, but can also be a directory name
54 or a dummy) to the directory specified by
55 .IR target .
56
57 Appropriate privilege (Linux: the
58 .B CAP_SYS_ADMIN
59 capability) is required to mount file systems.
60
61 Since Linux 2.4 a single file system can be visible at
62 multiple mount points, and multiple mounts can be stacked
63 on the same mount point.
64 .\" Multiple mounts on same mount point: since 2.3.99pre7.
65
66 Values for the
67 .I filesystemtype
68 argument supported by the kernel are listed in
69 .I /proc/filesystems
70 (like "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs",
71 "msdos", "proc", "nfs", "iso9660" etc.).
72 Further types may become available when the appropriate modules
73 are loaded.
74
75 The
76 .I mountflags
77 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
78 in the top 16 bits (this was required in kernel versions prior to 2.4, but
79 is no longer required and ignored if specified),
80 and various mount flags (as defined in \fI<linux/fs.h>\fP for libc4 and libc5
81 and in \fI<sys/mount.h>\fP for glibc2) in the low order 16 bits:
82 .\" FIXME 2.6.15 added flags for "shared sub-tree" functionality:
83 .\" MS_UNBINDABLE, MS_PRIVATE, MS_SHARED, MS_SLAVE
84 .\" These need to be documented on this page.
85 .\" See:
86 .\" Documentation/filesystems/sharedsubtree.txt
87 .\"
88 .\" http://lwn.net/Articles/159077/
89 .\"
90 .\" http://myweb.sudhaa.com:2022/~ram/sharedsubtree/paper/sharedsubtree.1.pdf
91 .\" Shared-Subtree Concept, Implementation, and Applications in Linux
92 .\" Al Viro viro@ftp.linux.org.uk
93 .\" Ram Pai linuxram@us.ibm.com
94 .\"
95 .\" http://foss.in/2005/slides/sharedsubtree1.pdf
96 .\" Shared Subtree Concept and Implementation in the Linux Kernel
97 .\" Ram Pai
98 .\"
99 .TP
100 .BR MS_BIND " (Linux 2.4 onwards)"
101 .\" since 2.4.0-test9
102 Perform a bind mount, making a file or a directory subtree visible at
103 another point within a file system.
104 Bind mounts may cross file system boundaries and span
105 .BR chroot (2)
106 jails.
107 The
108 .IR filesystemtype
109 and
110 .IR data
111 arguments are ignored.
112 Up until Linux 2.6.26,
113 .I mountflags
114 was also ignored
115 .\" with the exception of the "hidden" MS_REC mountflags bit
116 (the bind mount has the same mount options as
117 the underlying mount point).
118 Since Linux 2.6.26, the
119 .B MS_RDONLY
120 flag is honored when making a bind mount.
121 .TP
122 .BR MS_DIRSYNC " (since Linux 2.5.19)"
123 Make directory changes on this file system synchronous.
124 (This property can be obtained for individual directories
125 or subtrees using
126 .BR chattr (1).)
127 .TP
128 .B MS_MANDLOCK
129 Permit mandatory locking on files in this file system.
130 (Mandatory locking must still be enabled on a per-file basis,
131 as described in
132 .BR fcntl (2).)
133 .\" FIXME Say more about MS_MOVE
134 .TP
135 .B MS_MOVE
136 Move a subtree.
137 .I source
138 specifies an existing mount point and
139 .I target
140 specifies the new location.
141 The move is atomic: at no point is the subtree unmounted.
142 The
143 .IR filesystemtype ", " mountflags ", and " data
144 arguments are ignored.
145 .TP
146 .B MS_NOATIME
147 Do not update access times for (all types of) files on this file system.
148 .TP
149 .B MS_NODEV
150 Do not allow access to devices (special files) on this file system.
151 .TP
152 .B MS_NODIRATIME
153 Do not update access times for directories on this file system.
154 This flag provides a subset of the functionality provided by
155 .BR MS_NOATIME ;
156 that is,
157 .BR MS_NOATIME
158 implies
159 .BR MS_NODIRATIME .
160 .TP
161 .B MS_NOEXEC
162 Do not allow programs to be executed from this file system.
163 .\" (Possibly useful for a file system that contains non-Linux executables.
164 .\" Often used as a security feature, e.g., to make sure that restricted
165 .\" users cannot execute files uploaded using ftp or so.)
166 .TP
167 .B MS_NOSUID
168 Do not honor set-user-ID and set-group-ID bits when executing
169 programs from this file system.
170 .\" (This is a security feature to prevent users executing set-user-ID and
171 .\" set-group-ID programs from removable disk devices.)
172 .TP
173 .B MS_RDONLY
174 Mount file system read-only.
175 .\"
176 .\" FIXME Document MS_REC, available since 2.4.11.
177 .\" This flag has meaning in conjunction with MS_BIND and
178 .\" also with the shared sub-tree flags.
179 .TP
180 .BR MS_RELATIME " (Since Linux 2.6.20)"
181 When a file on this file system is accessed,
182 only update the file's last access time (atime) if the current value
183 of atime is less than or equal to the file's last modification time (mtime)
184 or last status change time (ctime).
185 This option is useful for programs, such as
186 .BR mutt (1),
187 that need to know when a file has been read since it was last modified.
188 .TP
189 .B MS_REMOUNT
190 Remount an existing mount.
191 This allows you to change the
192 .I mountflags
193 and
194 .I data
195 of an existing mount without having to unmount and remount the file system.
196 .I source
197 and
198 .I target
199 should be the same values specified in the initial
200 .BR mount ()
201 call;
202 .I filesystemtype
203 is ignored.
204
205 The following
206 .I mountflags
207 can be changed:
208 .BR MS_RDONLY ,
209 .BR MS_SYNCHRONOUS ,
210 .BR MS_MANDLOCK ;
211 before kernel 2.6.16, the following could also be changed:
212 .B MS_NOATIME
213 and
214 .BR MS_NODIRATIME ;
215 and, additionally, before kernel 2.4.10, the following could also be changed:
216 .BR MS_NOSUID ,
217 .BR MS_NODEV ,
218 .BR MS_NOEXEC .
219 .TP
220 .BR MS_SILENT " (since Linux 2.6.17)"
221 Suppress the display of certain
222 .RI ( printk ())
223 warning messages in the kernel log.
224 This flag supersedes the misnamed and obsolete
225 .BR MS_VERBOSE
226 flag (available since Linux 2.4.12), which has the same meaning.
227 .TP
228 .B MS_SYNCHRONOUS
229 Make writes on this file system synchronous (as though
230 the
231 .B O_SYNC
232 flag to
233 .BR open (2)
234 was specified for all file opens to this file system).
235 .PP
236 From Linux 2.4 onwards, the
237 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
238 flags are settable on a per-mount-point basis.
239 From kernel 2.6.16 onwards,
240 .B MS_NOATIME
241 and
242 .B MS_NODIRATIME
243 are also settable on a per-mount-point basis.
244 The
245 .B MS_RELATIME
246 flag is also settable on a per-mount-point basis.
247 .PP
248 The
249 .I data
250 argument is interpreted by the different file systems.
251 Typically it is a string of comma-separated options
252 understood by this file system.
253 See
254 .BR mount (8)
255 for details of the options available for each filesystem type.
256 .SH "RETURN VALUE"
257 On success, zero is returned.
258 On error, \-1 is returned, and
259 .I errno
260 is set appropriately.
261 .SH ERRORS
262 The error values given below result from filesystem type independent
263 errors.
264 Each filesystem type may have its own special errors and its
265 own special behavior.
266 See the kernel source code for details.
267 .TP
268 .B EACCES
269 A component of a path was not searchable.
270 (See also
271 .BR path_resolution (7).)
272 Or, mounting a read-only filesystem was attempted without giving the
273 .B MS_RDONLY
274 flag.
275 Or, the block device
276 .I source
277 is located on a filesystem mounted with the
278 .B MS_NODEV
279 option.
280 .\" mtk: Probably: write permission is required for MS_BIND, with
281 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
282 .TP
283 .B EBUSY
284 .I source
285 is already mounted.
286 Or, it cannot be remounted read-only,
287 because it still holds files open for writing.
288 Or, it cannot be mounted on
289 .I target
290 because
291 .I target
292 is still busy (it is the working directory of some task,
293 the mount point of another device, has open files, etc.).
294 .TP
295 .B EFAULT
296 One of the pointer arguments points outside the user address space.
297 .TP
298 .B EINVAL
299 .I source
300 had an invalid superblock.
301 Or, a remount
302 .RB ( MS_REMOUNT )
303 was attempted, but
304 .I source
305 was not already mounted on
306 .IR target .
307 Or, a move
308 .RB ( MS_MOVE )
309 was attempted, but
310 .I source
311 was not a mount point, or was \(aq/\(aq.
312 .TP
313 .B ELOOP
314 Too many links encountered during pathname resolution.
315 Or, a move was attempted, while
316 .I target
317 is a descendant of
318 .IR source .
319 .TP
320 .B EMFILE
321 (In case no block device is required:)
322 Table of dummy devices is full.
323 .TP
324 .B ENAMETOOLONG
325 A pathname was longer than
326 .BR MAXPATHLEN .
327 .TP
328 .B ENODEV
329 .I filesystemtype
330 not configured in the kernel.
331 .TP
332 .B ENOENT
333 A pathname was empty or had a nonexistent component.
334 .TP
335 .B ENOMEM
336 The kernel could not allocate a free page to copy filenames or data into.
337 .TP
338 .B ENOTBLK
339 .I source
340 is not a block device (and a device was required).
341 .TP
342 .B ENOTDIR
343 .IR target ,
344 or a prefix of
345 .IR source ,
346 is not a directory.
347 .TP
348 .B ENXIO
349 The major number of the block device
350 .I source
351 is out of range.
352 .TP
353 .B EPERM
354 The caller does not have the required privileges.
355 .SH "CONFORMING TO"
356 This function is Linux-specific and should not be used in
357 programs intended to be portable.
358 .SH NOTES
359 The original
360 .B MS_SYNC
361 flag was renamed
362 .B MS_SYNCHRONOUS
363 in 1.1.69
364 when a different
365 .B MS_SYNC
366 was added to \fI<mman.h>\fP.
367 .LP
368 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
369 on a filesystem mounted with
370 .B MS_NOSUID
371 would fail with
372 .BR EPERM .
373 Since Linux 2.4 the set-user-ID and set-group-ID bits are
374 just silently ignored in this case.
375 .\" The change is in patch-2.4.0-prerelease.
376 .SH "SEE ALSO"
377 .BR umount (2),
378 .BR path_resolution (7),
379 .BR mount (8),
380 .BR umount (8)