Fix path_rename on *nix hosts
The fix contains an errno remapping in macOS case where in case when we try to rename a file into a path with a trailing slash an ENOENT is returned. In this case, if the destination does not exist, an ENOTDIR should be thrown as is thrown correctly on Linux hosts. Thus, as a fix, if an ENOENT is thrown, an additional check is performed to see whether the destination path indeed contains a trailing slash, and if so, the errno is adjusted to ENOTDIR to match the POSIX/WASI spec.
This commit is contained in:
@@ -707,8 +707,11 @@ pub(crate) unsafe fn path_rename(
|
||||
let new_dirfd = wasi_ctx
|
||||
.get_fd_entry(new_dirfd, host::__WASI_RIGHT_PATH_RENAME_TARGET, 0)
|
||||
.and_then(|fe| fe.fd_object.descriptor.as_file())?;
|
||||
let resolved_old = path_get(old_dirfd, 0, old_path, false)?;
|
||||
let resolved_new = path_get(new_dirfd, 0, new_path, false)?;
|
||||
let resolved_old = path_get(old_dirfd, 0, old_path, true)?;
|
||||
let resolved_new = path_get(new_dirfd, 0, new_path, true)?;
|
||||
|
||||
log::debug!("path_rename resolved_old={:?}", resolved_old);
|
||||
log::debug!("path_rename resolved_new={:?}", resolved_new);
|
||||
|
||||
hostcalls_impl::path_rename(resolved_old, resolved_new)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user