diff --git a/Cargo.lock b/Cargo.lock index a2d68e3a..aa0180d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,12 +354,6 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" -[[package]] -name = "clean-path" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa6b4b263a5d737e9bf6b7c09b72c41a5480aec4d7219af827f6564e950b6a5" - [[package]] name = "colorchoice" version = "1.0.4" @@ -1672,7 +1666,6 @@ dependencies = [ "bitflags 2.10.0", "byte-unit", "clap", - "clean-path", "core_affinity", "criterion", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index fc296f3c..26ab0f3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/isolation/filemap.rs b/src/isolation/filemap.rs index 966813d1..27a57764 100644 --- a/src/isolation/filemap.rs +++ b/src/isolation/filemap.rs @@ -8,7 +8,6 @@ use std::{ path::PathBuf, }; -use clean_path::clean; use tempfile::TempDir; use uuid::Uuid; @@ -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 { - // 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:#?}"); diff --git a/src/isolation/mod.rs b/src/isolation/mod.rs index eb81bce6..684a8545 100644 --- a/src/isolation/mod.rs +++ b/src/isolation/mod.rs @@ -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. /// @@ -23,11 +21,12 @@ 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).or_else( + |_| absolute(host_str).unwrap(), + ).normalize_lexically().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)) } diff --git a/src/lib.rs b/src/lib.rs index aa4b1c03..20c6a9c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(normalize_lexically)] #![warn(rust_2018_idioms)] use std::path::PathBuf;