diff --git a/Cargo.lock b/Cargo.lock index 83d70890c3..c6b092310f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -432,9 +432,9 @@ dependencies = [ [[package]] name = "redox-path" -version = "0.3.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436d45c2b6a5b159d43da708e62b25be3a4a3d5550d654b72216ade4c4bfd717" +checksum = "64072665120942deff5fd5425d6c1811b854f4939e7f1c01ce755f64432bbea7" [[package]] name = "redox-rt" diff --git a/Cargo.toml b/Cargo.toml index 239f8f16f0..29a8b1d49b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ sc = "0.2.3" [target.'cfg(target_os = "redox")'.dependencies] redox_syscall = "0.5.13" redox-rt = { path = "redox-rt" } -redox-path = "0.3" +redox-path = "0.2" redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git", default-features = false, features = [ "redox_syscall", ] } diff --git a/src/platform/redox/path.rs b/src/platform/redox/path.rs index 467adef5d0..9d6739a463 100644 --- a/src/platform/redox/path.rs +++ b/src/platform/redox/path.rs @@ -5,7 +5,7 @@ use syscall::{data::Stat, error::*, flag::*}; use super::{libcscheme, FdGuard}; use crate::sync::Mutex; -pub use redox_path::{canonicalize_using_cwd, canonicalize_using_scheme, RedoxPath}; +pub use redox_path::canonicalize_using_cwd; // TODO: Define in syscall const PATH_MAX: usize = 4096; @@ -77,16 +77,27 @@ pub fn set_default_scheme(scheme: &str) -> Result<()> { fn canonicalize_with_cwd_internal(cwd: Option<&str>, path: &str) -> Result { let path = canonicalize_using_cwd(cwd, path).ok_or(Error::new(ENOENT))?; - if RedoxPath::from_absolute(&path) - .map(|rpath| rpath.is_legacy() || path.starts_with("/scheme/")) - .unwrap_or_default() - { - Ok(path) + let standard_scheme = path == "/scheme" || path.starts_with("/scheme/"); + let legacy_scheme = path + .split("/") + .next() + .map(|c| c.contains(":")) + .unwrap_or(false); + + Ok(if standard_scheme || legacy_scheme { + path } else { let mut default_scheme_guard = DEFAULT_SCHEME.lock(); let default_scheme = default_scheme_guard.get_or_insert_with(|| Box::from("file")); - canonicalize_using_scheme(default_scheme, &path).ok_or(Error::new(ENOENT)) - } + let mut result = format!("/scheme/{}{}", default_scheme, path); + + // Trim trailing / to keep path canonical. + if result.as_bytes().last() == Some(&b'/') { + result.pop(); + } + + result + }) } pub fn canonicalize(path: &str) -> Result {