From ff228d477e119f386850847e34cc588697d7b194 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Sat, 21 Sep 2019 01:07:14 -0400 Subject: [PATCH] paths that don't exist yet need to use canonicalize_parent() or else they will fail with ENOENT --- src/devices/virtio_9p/filesystem.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/devices/virtio_9p/filesystem.rs b/src/devices/virtio_9p/filesystem.rs index ee22f85..d928597 100644 --- a/src/devices/virtio_9p/filesystem.rs +++ b/src/devices/virtio_9p/filesystem.rs @@ -251,19 +251,19 @@ impl FileSystemOps for FileSystem { } fn symlink(&self, target: &Path, linkpath: &Path) -> io::Result<()> { - let linkpath = self.canonicalize(linkpath)?; + let linkpath = self.canonicalize_parent(linkpath)?; unix::fs::symlink(target, linkpath) } fn link(&self, target: &Path, newpath: &Path) -> io::Result<()> { let target = self.canonicalize(target)?; - let newpath= self.canonicalize(newpath)?; + let newpath= self.canonicalize_parent(newpath)?; fs::hard_link(target, newpath) } fn rename(&self, from: &Path, to: &Path) -> io::Result<()> { let from = self.canonicalize(from)?; - let to = self.canonicalize(to)?; + let to = self.canonicalize_parent(to)?; fs::rename(from, to) } @@ -278,7 +278,7 @@ impl FileSystemOps for FileSystem { } fn create_dir(&self, path: &Path, mode: u32) -> io::Result<()> { - let path = self.canonicalize(path)?; + let path = self.canonicalize_parent(path)?; fs::DirBuilder::new() .recursive(false) .mode(mode & 0o755)