Skip to content

Commit

Permalink
Base: Document mount(2) and mount(8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugaevc authored and awesomekling committed Jan 11, 2020
1 parent 0cb0f54 commit b37bd28
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Base/usr/share/man/man2/mount.md
Original file line number Diff line number Diff line change
@@ -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)
42 changes: 42 additions & 0 deletions Base/usr/share/man/man8/mount.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b37bd28

Please sign in to comment.