pub struct Mount { /* private fields */ }Expand description
A mount.
Implementations§
Source§impl Mount
impl Mount
Sourcepub fn bind<S: AsRef<OsStr>, D: AsRef<OsStr>>(source: S, destination: D) -> Self
pub fn bind<S: AsRef<OsStr>, D: AsRef<OsStr>>(source: S, destination: D) -> Self
Creates a bind mount. This effectively creates hardlink of a directory, making the contents accessible at both places.
By default, none of the mounts in the source directory are visible in
destination. To make all mounts recursively visible, combine this with
Mount::recursive. Can also be used with Mount::readonly to make
the contents of destination read-only.
Sourcepub fn rename<S: AsRef<OsStr>, D: AsRef<OsStr>>(
source: S,
destination: D,
) -> Self
pub fn rename<S: AsRef<OsStr>, D: AsRef<OsStr>>( source: S, destination: D, ) -> Self
Move/rename a mount.
Sourcepub fn devpts<S: AsRef<OsStr>>(target: S) -> Self
pub fn devpts<S: AsRef<OsStr>>(target: S) -> Self
Mount a fresh devpts file system. The target is usually /dev/pts.
In order for this devpts to be private and independent of other devpts (i.e., for containers), use:
Mount::devpts("/dev/pts").data("newinstance,ptmxmode=0666")And either make /dev/ptmx a symlink pointing to /dev/pts/ptmx or
bind-mount it.
See also: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
Sourcepub fn overlay(
lowerdir: &Path,
upperdir: &Path,
workdir: &Path,
merged: &Path,
) -> Self
pub fn overlay( lowerdir: &Path, upperdir: &Path, workdir: &Path, merged: &Path, ) -> Self
Mount an overlay file system.
NOTE: This only works in Linux 5.11 or newer when mounted from a user namespace. Otherwise, you need real root privileges to mount an overlayfs.
An overlay filesystem combines two filesystems - an upper filesystem and a lower filesystem. When a name exists in both filesystems, the object in the upper filesystem is visible while the object in the lower filesystem is either hidden or, in the case of directories, merged with the upper object.
In other words, the lowerdir and upperdir are combined into a
directory merged using workdir as a temporary work area.
The lower filesystem can be any filesystem supported by Linux and does not need to be writable. The lower filesystem can even be another overlayfs. The upper filesystem should be writable.
See https://www.kernel.org/doc/html/latest/filesystems/overlayfs.html for more information.
§Arguments
lowerdir- The lower directory of the overlay. Can be any filesystem and does not need to be writable. This directory is never modified by writes tomerged.upperdir- The upper directory of the overlay. This is where all changes tomergedare collected. Does not need to be empty, but should be when starting a new overlay from scratch.workdir- The work directory. This should always be empty.merged- The combination oflowerdirandupperdir.
Sourcepub fn tmpfs<S: AsRef<OsStr>>(target: S) -> Self
pub fn tmpfs<S: AsRef<OsStr>>(target: S) -> Self
Creates a temporary file system at the location specified.
Sourcepub fn sysfs<S: AsRef<OsStr>>(target: S) -> Self
pub fn sysfs<S: AsRef<OsStr>>(target: S) -> Self
Creates a sys file system at the location specified. The target directory
is usually /sys. This is useful when creating a network namespace.
Sourcepub fn get_target(&self) -> &Path
pub fn get_target(&self) -> &Path
Returns the mount point target path.
Sourcepub fn get_source(&self) -> Option<&Path>
pub fn get_source(&self) -> Option<&Path>
Returns the mount point source path (if any).
Sourcepub fn touch_target(self) -> Self
pub fn touch_target(self) -> Self
Indicates that the target of a bind mount should be created automatically.
Sourcepub fn flags(self, flags: MountFlags) -> Self
pub fn flags(self, flags: MountFlags) -> Self
Adds mount flags.
Sourcepub fn allow_readonly_fallback(self) -> Self
pub fn allow_readonly_fallback(self) -> Self
Allows a new writable proc mount that fails with EPERM to retry read-only.
This explicitly permits the resulting mount to be less capable than requested. It has no effect on non-proc or already-read-only mounts, remounts, bind mounts, moves, or propagation changes.
Sourcepub fn private(self) -> Self
pub fn private(self) -> Self
Makes this mount point private. Mount and unmount events do not propagate into or out of this mount point.
Make this mount point shared. Mount and unmount events immediately under this mount point will propagate to the other mount points that are members of this mount’s peer group. Propagation here means that the same mount or unmount will automatically occur under all of the other mount points in the peer group. Conversely, mount and unmount events that take place under peer mount points will propagate to this mount point.
Sourcepub fn rprivate(self) -> Self
pub fn rprivate(self) -> Self
Same as specifying both Mount::recursive and Mount::private.
Same as specifying both Mount::recursive and Mount::shared.
Trait Implementations§
impl Eq for Mount
Source§impl FromStr for Mount
impl FromStr for Mount
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses a Mount. This accepts the same syntax as Docker mounts where
each mount consists of a comma-separated key-value list.
See https://docs.docker.com/storage/bind-mounts/ for more information.