Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ instrument = ["rftrace", "rftrace-frontend"]
align-address = "0.3.0"
byte-unit = { version = "5", features = ["byte", "serde"] }
clap = { version = "4.5", features = ["derive", "env"] }
clean-path = "0.2.1"
core_affinity = "0.8"
env_logger = "0.11"
gdbstub = "0.7"
Expand Down
7 changes: 3 additions & 4 deletions src/isolation/filemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
path::PathBuf,
};

use clean_path::clean;
use tempfile::TempDir;
use uuid::Uuid;

Expand Down Expand Up @@ -46,9 +45,9 @@ impl UhyveFileMap {
///
/// * `guest_path` - The guest path that is to be looked up in the map.
pub fn get_host_path(&self, guest_path: &CStr) -> Option<OsString> {
// TODO: Replace clean-path in favor of Path::normalize_lexically, which has not
// been implemented yet. See: https://github.com/rust-lang/libs-team/issues/396
let guest_pathbuf = clean(OsStr::from_bytes(guest_path.to_bytes()));
let guest_pathbuf: PathBuf = PathBuf::from(OsStr::from_bytes(guest_path.to_bytes()))
.normalize_lexically()
.ok()?;
if let Some(host_path) = self.files.get(&guest_pathbuf) {
let host_path = OsString::from(host_path);
trace!("get_host_path (host_path): {host_path:#?}");
Expand Down
12 changes: 6 additions & 6 deletions src/isolation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ pub mod tempdir;
use std::{
fs::canonicalize,
io::ErrorKind,
path::{PathBuf, absolute},
path::{Path, PathBuf, absolute},
};

use clean_path::clean;

/// Separates a string of the format "./host_dir/host_path.txt:guest_path.txt"
/// into a guest_path (String) and host_path (OsString) respectively.
///
Expand All @@ -23,11 +21,13 @@ fn split_guest_and_host_path(mapping: &str) -> Result<(PathBuf, PathBuf), ErrorK

// TODO: Replace clean-path in favor of Path::normalize_lexically, which has not
// been implemented yet. See: https://github.com/rust-lang/libs-team/issues/396
let host_path =
canonicalize(host_str).map_or_else(|_| clean(absolute(host_str).unwrap()), clean);
let host_path = canonicalize(host_str).map_or_else(
|_| absolute(host_str).unwrap().normalize_lexically().unwrap(),
|path| Path::normalize_lexically(&path).unwrap(),
);

// `.to_str().unwrap()` should never fail because `guest_str` is always valid UTF-8
let guest_path = PathBuf::from(clean(guest_str).to_str().unwrap());
let guest_path = PathBuf::from(guest_str).normalize_lexically().unwrap();

Ok((guest_path, host_path))
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(normalize_lexically)]
#![warn(rust_2018_idioms)]

use std::path::PathBuf;
Expand Down
Loading