Skip to content

Commit 26724f3

Browse files
committed
filesystem: ErrorCode::NotPermitted when hard-linking directory
On Windows, attempting to hard-link a directory gave ErrorCode::Access instead of NotPermitted. Fix it in the wasi crate instead of cap-std or wasi-common because it's where the sync/tokio configurations flow. Should fix wasmtime for WebAssembly/wasi-testsuite#177.
1 parent 69ef9af commit 26724f3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crates/wasi/src/filesystem.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,15 @@ impl Dir {
920920
return Err(ErrorCode::Invalid);
921921
}
922922
let new_dir_handle = Arc::clone(&new_dir.dir);
923-
self.run_blocking(move |d| d.hard_link(&old_path, &new_dir_handle, &new_path))
924-
.await?;
925-
Ok(())
923+
match self
924+
.run_blocking(move |d| d.hard_link(&old_path, &new_dir_handle, &new_path))
925+
.await
926+
{
927+
#[cfg(windows)]
928+
Err(ErrorCode::Access) => Err(ErrorCode::NotPermitted),
929+
Ok(()) => Ok(()),
930+
Err(err) => Err(err.into()),
931+
}
926932
}
927933

928934
pub(crate) async fn open_at(

0 commit comments

Comments
 (0)