Handle new path format

This commit is contained in:
Jeremy Soller
2024-01-18 12:35:32 -07:00
parent 0e58953259
commit 87ee68998c
4 changed files with 13 additions and 8 deletions
Generated
+5
View File
@@ -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"
+1
View File
@@ -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.
+6 -7
View File
@@ -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<FileHandle> {
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,