Skip to content

Commit

Permalink
fix(uhyvefilemap): use a Uuid for new temporary files
Browse files Browse the repository at this point in the history
Ported from #816, fixes a regression introduced by
hermit-os/kernel#1529,
which modified the Hermit kernel so that it uses absolute paths instead
of relative ones.
  • Loading branch information
n0toose authored and jounathaen committed Jan 9, 2025
1 parent cf07481 commit 92f11ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/isolation/filemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
};

use tempfile::TempDir;
use uuid::Uuid;

use crate::isolation::tempdir::create_temp_dir;

Expand Down Expand Up @@ -102,8 +103,11 @@ impl UhyveFileMap {
///
/// * `guest_path` - The requested guest path.
pub fn create_temporary_file(&mut self, guest_path: &str) -> CString {
// TODO: Do we need to canonicalize the host_path?
let host_path = self.tempdir.path().join(guest_path).into_os_string();
let host_path = self
.tempdir
.path()
.join(Uuid::new_v4().to_string())
.into_os_string();
let ret = CString::new(host_path.as_bytes()).unwrap();
self.files.insert(String::from(guest_path), host_path);
ret
Expand Down

0 comments on commit 92f11ef

Please sign in to comment.