Base: Document mount(2) and mount(8)

This commit is contained in:
Sergey Bugaev 2020-01-11 19:54:48 +03:00 committed by Andreas Kling
parent 0cb0f54783
commit b37bd28053
Notes: sideshowbarker 2024-07-19 10:11:10 +09:00
2 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,53 @@
## Name
mount - mount a filesystem
## Synopsis
```**c++
#include <unistd.h>
int mount(const char* source, const char* target, const char* fs_type, int flags);
```
## Description
`mount()` mounts a filesystem stored at `source` by overlaying its contents over `target`.
`fs_type` must be one of the following supported filesystems:
* `Ext2FS` (or `ext2`): The ext2 filesystem.
* `ProcFS` (or `proc`): The process pseudo-filesystem (normally mounted at `/proc`).
* `DevPtsFS` (or `devpts`): The pseudoterminal pseudo-filesystem (normally mounted at `/dev/pts`).
* `TmpFS` (or `tmp`): A non-persistent filesystem that stores all its data in RAM. An instance of this filesystem is normally mounted at `/tmp`.
For Ext2FS, `source` must be a path to a block device storing the filesystem contents. All
the other filesystems ignore the `source` argument (by convention, it should have the same
value as `fs_type`).
The following `flags` are supported:
* `MS_NODEV`: Disallow opening any devices from this file system.
* `MS_NOEXEC`: Disallow executing any executables from this file system.
* `MS_NOSUID`: Ignore set-user-id bits on executables from this file system.
* `MS_BIND`: Perform a bind-mount (see below).
These flags can be used as a security measure to limit the possible abuses of the newly
mounted file system.
### Bind mounts
If `MS_BIND` is specified in `flags`, `fs_type` is ignored and a bind mount is performed
instead. In this case `source` is treated as a path to a file or directory whose contents
are overlayed over `target`. This can be used as an alternative to symlinks or hardlinks.
## Errors
* `EPERM`: The current process does not have superuser privileges.
* `ENODEV`: The `fs_type` is unrecognized, or the device is not found, or the device doesn't contain a valid filesystem image.
All of the usual path resolution errors may also occur.
## See also
* [`mount`(8)](../man8/mount.md)

View file

@ -0,0 +1,42 @@
## Name
mount - mount a filesystem
## Synopsis
```**sh
$ mount
# mount -a
# mount <source> <target> [-t fstype] [-o options]
```
## Description
If invoked without any arguments, `mount` prints a list of all currently mounted filesystems.
If invoked as `mount -a`, `mount` mounts all the filesystems configured in `/etc/fstab`. This
is normally done on system startup by [`SystemServer`(7)](../man7/SystemServer.md).
Otherwise, `mount` performs a single filesystem mount. Source, target, and fstype have the
same meaning as in the [`mount`(2)](../man2/mount.md) syscall (if not specified, fstype
defaults to `ext2`).
Options correspond to the mount flags, and should be specified as a comma-separated list of
flag names (lowercase and without the `MS_` prefix). Additionally, the name `defaults` is
accepted and ignored.
## Files
* `/etc/fstab` - read by `mount -a` on startup to find out which filesystems to mount.
* `/proc/df` - read by `mount` to get information about mounted filesystems.
## Examples
```sh
# mount devpts /dev/pts -t devpts -o noexec,nosuid
# mount /home/anon/myfile.txt /tmp/foo -o bind
```
## See also
* [`mount`(2)](../man2/mount.md)