Skip to content

Commit

Permalink
mount: Move /etc/resolv.conf backing file to /run and generalize
Browse files Browse the repository at this point in the history
Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Dec 29, 2024
1 parent 7d4fe9d commit e346250
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/muvm/src/guest/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,13 @@ pub fn overlay_file(src: &str, dest: &str) -> Result<()> {
.with_context(|| format!("Failed to move_mount {src:?} to {dest:?}"))
}

pub fn place_etc(file: &str, contents: Option<&str>) -> Result<()> {
let tmp = "/tmp/".to_string() + file;
let etc = "/etc/".to_string() + file;

pub fn place_file(backing: &str, dest: &str, contents: Option<&str>) -> Result<()> {
{
let mut file = File::options()
.write(true)
.create(true)
.truncate(true)
.open(&tmp)
.open(backing)
.context("Failed to create temp backing of an etc file")?;

if let Some(content) = contents {
Expand All @@ -274,13 +271,13 @@ pub fn place_etc(file: &str, contents: Option<&str>) -> Result<()> {
}
}

overlay_file(&tmp, &etc)
overlay_file(backing, dest)
}

pub fn mount_filesystems() -> Result<()> {
make_tmpfs("/var/run")?;

place_etc("resolv.conf", None)?;
place_file("/run/resolv.conf", "/etc/resolv.conf", None)?;

mount2(
Some("binfmt_misc"),
Expand Down

0 comments on commit e346250

Please sign in to comment.