Skip to content

Commit

Permalink
Merge pull request #2953 from Gekko0114/mount
Browse files Browse the repository at this point in the history
create mount_rootfs method
  • Loading branch information
YJDoc2 authored Nov 6, 2024
2 parents 04c35e5 + fbb5d58 commit 444cc4f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions crates/libcontainer/src/rootfs/rootfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit 444cc4f

Please sign in to comment.