From 87ee68998cde656563f61e53acbfbc040a78fcb5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 18 Jan 2024 12:35:32 -0700 Subject: [PATCH] Handle new path format --- Cargo.lock | 5 +++++ Cargo.toml | 1 + redox-path | 2 +- src/syscall/fs.rs | 13 ++++++------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 759e5cb468..99ea28edd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,6 +120,7 @@ dependencies = [ "log", "paste", "raw-cpuid", + "redox-path", "redox_syscall", "rmm", "rustc-cfg", @@ -218,6 +219,10 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox-path" +version = "0.1.1" + [[package]] name = "redox_syscall" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index 38d63919a7..eb7fc6f697 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ bitfield = "0.13.2" hashbrown = { version = "0.14.3", default-features = false, features = ["ahash", "inline-more"] } linked_list_allocator = "0.9.0" log = "0.4" +redox-path = { path = "redox-path" } redox_syscall = { path = "syscall" } slab_allocator = { path = "slab_allocator", optional = true } # FIXME: There is some undefined behavior probably in the kernel, which forces us to use spin 0.9.0 and not 0.9.2. diff --git a/redox-path b/redox-path index 8e1969528d..2971b40d34 160000 --- a/redox-path +++ b/redox-path @@ -1 +1 @@ -Subproject commit 8e1969528d440587aba5138f0b6265bf8faa847c +Subproject commit 2971b40d3462476bf77c0fdbe6cb0e6368f5c269 diff --git a/src/syscall/fs.rs b/src/syscall/fs.rs index 23339c463f..3f45072630 100644 --- a/src/syscall/fs.rs +++ b/src/syscall/fs.rs @@ -1,5 +1,6 @@ //! Filesystem syscalls use alloc::{sync::Arc, vec::Vec}; +use redox_path::RedoxPath; use spin::RwLock; use crate::{ @@ -81,22 +82,20 @@ pub fn open(raw_path: UserSliceRo, flags: usize) -> Result { let mut path_buf = BorrowedHtBuf::head()?; let path = path_buf.use_for_string(raw_path)?; */ - let path = copy_path_to_buf(raw_path, PATH_MAX)?; - - let mut parts = path.splitn(2, ':'); - let scheme_name = parts.next().ok_or(Error::new(EINVAL))?; - let reference = parts.next().unwrap_or(""); + let path_buf = copy_path_to_buf(raw_path, PATH_MAX)?; + let path = RedoxPath::from_absolute(&path_buf).ok_or(Error::new(EINVAL))?; + let (scheme_name, reference) = path.as_parts(); let description = { let (scheme_id, scheme) = { let schemes = scheme::schemes(); let (scheme_id, scheme) = schemes - .get_name(scheme_ns, scheme_name) + .get_name(scheme_ns, scheme_name.as_ref()) .ok_or(Error::new(ENODEV))?; (scheme_id, scheme.clone()) }; - match scheme.kopen(reference, flags, CallerCtx { uid, gid, pid })? { + match scheme.kopen(reference.as_ref(), flags, CallerCtx { uid, gid, pid })? { OpenResult::SchemeLocal(number) => Arc::new(RwLock::new(FileDescription { namespace: scheme_ns, scheme: scheme_id,