Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion crates/wasi/src/p3/filesystem/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,23 @@ impl types::HostDescriptorWithStore for WasiFilesystem {
path: String,
) -> FilesystemResult<()> {
let dir = store.get_dir(&fd)?;
dir.unlink_file_at(path).await?;
dir.unlink_file_at(path).await.map_err(|e| {
match e {
// Linux returns EISDIR when attempting to unlink a
// directory instead of the POSIX-specified EPERM.
crate::filesystem::ErrorCode::IsDirectory => ErrorCode::NotPermitted,
// Windows on the other hand returns EACCESS when
// attempting to unlink a directory. Unfortunately
// filesystem ownership and permissions can also give
// rise to EACCESS, on Windows and elsewhere. However
// give filestem permissions aren't part of WASI, we can
// regain a single behavior if we reduce the precision
// on these errors by mapping all EACCESS errors to
// EPERM, on all platforms.
crate::filesystem::ErrorCode::Access => ErrorCode::NotPermitted,
e => e.into(),
}
})?;
Ok(())
}

Expand Down