Skip to content

Commit

Permalink
Let's fix the UNC logic in mount_directory_entries() instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed May 31, 2023
1 parent 647ca86 commit 78e52ea
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/virtual-fs/src/mem_fs/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,22 @@ impl FileSystem {
&self,
target_path: &Path,
other: &Arc<dyn crate::FileSystem + Send + Sync>,
source_path: &Path,
mut source_path: &Path,
) -> Result<()> {
let fs_lock = self.inner.read().map_err(|_| FsError::Lock)?;

if cfg!(windows) {
// We need to take some care here because
// canonicalize_without_inode() doesn't accept Windows paths that
// start with a prefix (drive letters, UNC paths, etc.). If we
// somehow get one of those paths, we'll automatically trim it away.
let mut components = source_path.components();

if let Some(Component::Prefix(_)) = components.next() {
source_path = components.as_path();
}
}

let (_target_path, root_inode) = match fs_lock.canonicalize(target_path) {
Ok((p, InodeResolution::Found(inode))) => (p, inode),
Ok((_p, InodeResolution::Redirect(..))) => {
Expand Down Expand Up @@ -882,7 +894,7 @@ impl FileSystemInner {
let mut components = path.components();

match components.next() {
Some(Component::RootDir) | Some(Component::Prefix(..)) => {}
Some(Component::RootDir) => {}
_ => return Err(FsError::InvalidInput),
}

Expand Down

0 comments on commit 78e52ea

Please sign in to comment.