pub struct Mount { /* private fields */ }Implementations§
Source§impl Mount
impl Mount
pub fn new() -> Mount
pub fn with_mountinfo_provider<P: MountInfoProvider + 'static>( self, provider: P, ) -> Self
pub fn setup_mount( &self, mount: &SpecMount, options: &MountOptions<'_>, ) -> Result<(), MountError>
Sourcepub fn make_parent_mount_private(
&self,
rootfs: &Path,
) -> Result<MountInfo, MountError>
pub fn make_parent_mount_private( &self, rootfs: &Path, ) -> Result<MountInfo, MountError>
Make parent mount of rootfs private if it was shared, which is required by pivot_root. It also makes sure following bind mount does not propagate in other namespaces.
Sourcepub fn check_proc_mount(
&self,
rootfs: &Path,
mount: &SpecMount,
) -> Result<(), MountError>
pub fn check_proc_mount( &self, rootfs: &Path, mount: &SpecMount, ) -> Result<(), MountError>
check_proc_mount checks to ensure that the mount destination is not over the top of /proc. dest is required to be an abs path and have any symlinks resolved before calling this function.
§Example (a valid case where /proc is mounted with proc type.)
use std::path::PathBuf;
use oci_spec::runtime::MountBuilder as SpecMountBuilder;
use libcontainer::rootfs::Mount;
let mounter = Mount::new();
let rootfs = PathBuf::from("/var/lib/my-runtime/containers/abcd1234/rootfs");
let destination = PathBuf::from("/proc");
let source = PathBuf::from("proc");
let typ = "proc";
let mount = SpecMountBuilder::default()
.destination(destination)
.typ(typ)
.source(source)
.build()
.expect("failed to build SpecMount");
assert!(mounter.check_proc_mount(rootfs.as_path(), &mount).is_ok());§Example (bind mount to /proc that should fail)
use std::path::PathBuf;
use oci_spec::runtime::MountBuilder as SpecMountBuilder;
use libcontainer::rootfs::Mount;
let mounter = Mount::new();
let rootfs = PathBuf::from("/var/lib/my-runtime/containers/abcd1234/rootfs");
let destination = PathBuf::from("/proc");
let source = PathBuf::from("/tmp");
let typ = "bind";
let mount = SpecMountBuilder::default()
.destination(destination)
.typ(typ)
.source(source)
.build()
.expect("failed to build SpecMount");
assert!(mounter.check_proc_mount(rootfs.as_path(), &mount).is_err());Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mount
impl !RefUnwindSafe for Mount
impl !Send for Mount
impl !Sync for Mount
impl Unpin for Mount
impl UnsafeUnpin for Mount
impl !UnwindSafe for Mount
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more