From 18a552eaa37f295ff09fb505e3535b84062744d3 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 10 Aug 2022 14:01:40 +0200 Subject: [PATCH] Fixed an issue when renaming a file from a preopened dir directly (for #3084) --- lib/wasi/src/syscalls/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 871feb32a47..51f7595f20c 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -2649,6 +2649,13 @@ pub fn path_rename( } } + // this is to be sure the source file is fetch from filesystem if needed + wasi_try!(state.fs.get_inode_at_path( + inodes.deref_mut(), + old_fd, + source_path.to_str().as_ref().unwrap(), + true + )); let (source_parent_inode, source_entry_name) = wasi_try!(state .fs @@ -2657,7 +2664,6 @@ pub fn path_rename( wasi_try!(state .fs .get_parent_inode_at_path(inodes.deref_mut(), new_fd, target_path, true)); - let host_adjusted_target_path = { let guard = inodes.arena[target_parent_inode].read(); let deref = guard.deref();