diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 51f7595f20c..0c5266e6efc 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -2656,6 +2656,18 @@ pub fn path_rename( source_path.to_str().as_ref().unwrap(), true )); + if state + .fs + .get_inode_at_path( + inodes.deref_mut(), + new_fd, + target_path.to_str().as_ref().unwrap(), + true, + ) + .is_ok() + { + return __WASI_EEXIST; + } let (source_parent_inode, source_entry_name) = wasi_try!(state .fs