Skip to content

Commit a336fed

Browse files
hoshinolinaslp
authored andcommitted
mount: Move /etc/resolv.conf backing file to /run and generalize
Signed-off-by: Asahi Lina <[email protected]>
1 parent ab04a1e commit a336fed

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

crates/muvm/src/guest/mount.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,13 @@ pub fn overlay_file(src: &str, dest: &str) -> Result<()> {
267267
.with_context(|| format!("Failed to move_mount {src:?} to {dest:?}"))
268268
}
269269

270-
pub fn place_etc(file: &str, contents: Option<&str>) -> Result<()> {
271-
let tmp = "/tmp/".to_string() + file;
272-
let etc = "/etc/".to_string() + file;
273-
270+
pub fn place_file(backing: &str, dest: &str, contents: Option<&str>) -> Result<()> {
274271
{
275272
let mut file = File::options()
276273
.write(true)
277274
.create(true)
278275
.truncate(true)
279-
.open(&tmp)
276+
.open(backing)
280277
.context("Failed to create temp backing of an etc file")?;
281278

282279
if let Some(content) = contents {
@@ -285,13 +282,13 @@ pub fn place_etc(file: &str, contents: Option<&str>) -> Result<()> {
285282
}
286283
}
287284

288-
overlay_file(&tmp, &etc)
285+
overlay_file(backing, dest)
289286
}
290287

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

294-
place_etc("resolv.conf", None)?;
291+
place_file("/run/resolv.conf", "/etc/resolv.conf", None)?;
295292

296293
mount2(
297294
Some("binfmt_misc"),

0 commit comments

Comments
 (0)