diff --git a/Cargo.lock b/Cargo.lock index d8853e3192e204ce14f8b6c17e1ca38c44247a35..8ecfd8f65becda625996f8b737f2a83f04c2818c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,9 +262,9 @@ checksum = "384c2842d4e069d5ccacf5fe1dca4ef8d07a5444329715f0fc3c61813502d4d1" [[package]] name = "redox-path" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64072665120942deff5fd5425d6c1811b854f4939e7f1c01ce755f64432bbea7" +checksum = "d515f4eec916ba5ea351bd7ad7b25232af420282e88c932b29b2a4e807538e19" [[package]] name = "redox_simple_endian" diff --git a/Cargo.toml b/Cargo.toml index bca0e1d1e416dd0430e8da3129a40fa88f2b0642..41853799be9c6d3f6ae3e53151ca55682b498596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ range-tree = { version = "0.1", optional = true } seahash = { version = "4.1.0", default-features = false } termion = { version = "1.5.6", optional = true } uuid = { version = "1.4", default-features = false } -redox-path = "0.2.0" +redox-path = "0.3.0" # https://github.com/rexlunae/simple-endian-rs/pull/5 [dependencies.redox_simple_endian] diff --git a/src/bin/mount.rs b/src/bin/mount.rs index d6e2f0234087cca30383e4ecc7b574a39ac8fffe..479308b4285f7050363dad24d1afe2b340692757 100644 --- a/src/bin/mount.rs +++ b/src/bin/mount.rs @@ -207,17 +207,19 @@ fn filesystem_by_uuid( ) -> Option<(String, FileSystem<DiskCache<DiskFile>>)> { use std::fs; - use redox_path::canonicalize_using_scheme; + use redox_path::RedoxPath; match fs::read_dir("/scheme") { Ok(entries) => { for entry_res in entries { if let Ok(entry) = entry_res { - if let Ok(scheme) = entry.file_name().into_string() { - if scheme.starts_with("disk") { - println!("redoxfs: found scheme {}", scheme); - let scheme_path = canonicalize_using_scheme(&scheme, "")?; - match fs::read_dir(scheme_path) { + if let Some(disk) = entry.path().to_str() { + if RedoxPath::from_absolute(disk) + .unwrap_or(RedoxPath::from_absolute("/")?) + .is_scheme_category("disk") + { + println!("redoxfs: found scheme {}", disk); + match fs::read_dir(disk) { Ok(entries) => { for entry_res in entries { if let Ok(entry) = entry_res { @@ -249,7 +251,7 @@ fn filesystem_by_uuid( } } Err(err) => { - println!("redoxfs: failed to list '{}': {}", scheme, err); + println!("redoxfs: failed to list '{}': {}", disk, err); } } } diff --git a/src/mount/redox/scheme.rs b/src/mount/redox/scheme.rs index 80bd73b2fe74e789e7064d3d139c335b40110486..98f42d14050dfa066e66e2184f9804c00040b388 100644 --- a/src/mount/redox/scheme.rs +++ b/src/mount/redox/scheme.rs @@ -15,7 +15,7 @@ use syscall::flag::{ use syscall::scheme::SchemeMut; use syscall::{MunmapFlags, EBADFD}; -use redox_path::{canonicalize_using_cwd, canonicalize_using_scheme, RedoxPath}; +use redox_path::{canonicalize_to_standard, canonicalize_using_cwd, canonicalize_using_scheme, scheme_path, RedoxPath}; use crate::{Disk, FileSystem, Node, Transaction, TreeData, TreePtr, BLOCK_SIZE}; @@ -50,10 +50,10 @@ impl<D: Disk> FileScheme<D> { nodes: &mut Vec<(TreeData<Node>, String)>, ) -> Result<String> { let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); - let scheme_path = canonicalize_using_scheme(scheme_name, "").ok_or(Error::new(EINVAL))?; // symbolic link is relative to this part of the url - let mut working_dir = dirname(full_path).unwrap_or(scheme_path.to_string()); + let mut working_dir = + dirname(full_path).unwrap_or(scheme_path(scheme_name).ok_or(Error::new(EINVAL))?); // node of the link let mut node = node; @@ -69,40 +69,18 @@ impl<D: Disk> FileScheme<D> { atime.subsec_nanos(), )?; - let target = canonicalize_using_cwd( + let target = canonicalize_to_standard( Some(&working_dir), str::from_utf8(&buf[..count]).or(Err(Error::new(EINVAL)))?, ) .ok_or(Error::new(EINVAL))?; let target_as_path = RedoxPath::from_absolute(&target).ok_or(Error::new(EINVAL))?; - let target_reference = match target_as_path { - RedoxPath::Standard(_) => { - let (scheme, reference) = - target_as_path.as_parts().ok_or(Error::new(EINVAL))?; - if scheme.as_ref() != scheme_name { - return Err(Error::new(EXDEV)); - } - reference.as_ref().to_string() - } - RedoxPath::Legacy(scheme, reference) => { - // Legacy references are not canonicalized because they can contain coded information - // We know this is a `file:` reference, so canonicalize into a Standard path - if scheme.as_ref() != scheme_name { - return Err(Error::new(EXDEV)); - } - let target = canonicalize_using_scheme(scheme_name, reference.as_ref()) - .ok_or(Error::new(EINVAL))?; - let target_as_path = - RedoxPath::from_absolute(&target).ok_or(Error::new(EINVAL))?; - let (scheme, reference) = - target_as_path.as_parts().ok_or(Error::new(EINVAL))?; - if scheme.as_ref() != scheme_name { - return Err(Error::new(EXDEV)); - } - reference.as_ref().to_string() - } - }; + let (scheme, reference) = target_as_path.as_parts().ok_or(Error::new(EINVAL))?; + if scheme.as_ref() != scheme_name { + return Err(Error::new(EXDEV)); + } + let target_reference = reference.to_string(); nodes.clear(); if let Some((next_node, next_node_name)) = @@ -110,7 +88,7 @@ impl<D: Disk> FileScheme<D> { { if !next_node.data().is_symlink() { nodes.push((next_node, next_node_name)); - return Ok(target_reference.to_string()); + return Ok(target_reference); } node = next_node; working_dir = dirname(&target).ok_or(Error::new(EINVAL))?.to_string();