From fbb5d58588b3dadfb5130623aba772995ed6c297 Mon Sep 17 00:00:00 2001 From: Hiroyuki Moriya <41197469+Gekko0114@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:22:35 +0000 Subject: [PATCH] create mount_rootfs method Signed-off-by: Hiroyuki Moriya <41197469+Gekko0114@users.noreply.github.com> --- crates/libcontainer/src/rootfs/rootfs.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/libcontainer/src/rootfs/rootfs.rs b/crates/libcontainer/src/rootfs/rootfs.rs index e7413833..a378e52b 100644 --- a/crates/libcontainer/src/rootfs/rootfs.rs +++ b/crates/libcontainer/src/rootfs/rootfs.rs @@ -31,17 +31,14 @@ impl RootFS { } } - pub fn prepare_rootfs( + pub fn mount_to_rootfs( &self, + linux: &Linux, spec: &Spec, rootfs: &Path, - bind_devices: bool, cgroup_ns: bool, ) -> Result<()> { - tracing::debug!(?rootfs, "prepare rootfs"); let mut flags = MsFlags::MS_REC; - let linux = spec.linux().as_ref().ok_or(MissingSpecError::Linux)?; - match linux.rootfs_propagation().as_deref() { Some("shared") => flags |= MsFlags::MS_SHARED, Some("private") => flags |= MsFlags::MS_PRIVATE, @@ -92,6 +89,20 @@ impl RootFS { mounter.setup_mount(mount, &global_options)?; } } + Ok(()) + } + + pub fn prepare_rootfs( + &self, + spec: &Spec, + rootfs: &Path, + bind_devices: bool, + cgroup_ns: bool, + ) -> Result<()> { + tracing::debug!(?rootfs, "prepare rootfs"); + let linux = spec.linux().as_ref().ok_or(MissingSpecError::Linux)?; + + self.mount_to_rootfs(linux, spec, rootfs, cgroup_ns)?; let symlinker = Symlink::new(); symlinker.setup_kcore_symlink(rootfs)?;