Revert "Merge branch 'use-redox-path-in-cwd' into 'master'"

This reverts merge request !669
This commit is contained in:
Jeremy Soller
2025-07-11 06:28:48 -06:00
parent e86bbb0856
commit b68ff56115
3 changed files with 22 additions and 11 deletions
Generated
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -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",
] }
+19 -8
View File
@@ -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<String> {
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<String> {