Skip to content

Conversation

@wingo
Copy link

@wingo wingo commented Dec 16, 2025

Unfortunately only MacOS has the POSIX behavior of returning EPERM when unlinking a directory; Linux returns EISDIR, and Windows returns EACCESS. Because EACCESS may arise for other reasons but which are outside the purview of WASI, we map all EACCESS to EPERM.

Unfortunately only MacOS has the POSIX behavior of returning EPERM when
unlinking a directory; Linux returns EISDIR, and Windows returns
EACCESS.  Because EACCESS may arise for other reasons but which are
outside the purview of WASI, we map all EACCESS to EPERM.
@wingo wingo requested a review from a team as a code owner December 16, 2025 09:29
@github-actions github-actions bot added the P-filesystem Proposal: wasi-filesystem label Dec 16, 2025
wingo added a commit to wingo/wasmtime that referenced this pull request Dec 16, 2025
When attempting to unlink a directory, POSIX specifies the result should
be EPERM, but only MacOS implements that behavior.  Paper over the
differences.  Also turn EACCESS into EPERM, to paper over Windows
differences.

Related to WebAssembly/WASI#852 and
WebAssembly/wasi-testsuite#137.

POSIX 2008 reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
wingo added a commit to wingo/wasi-testsuite that referenced this pull request Dec 16, 2025
wingo added a commit to wingo/wasmtime that referenced this pull request Dec 16, 2025
When attempting to unlink a directory, POSIX specifies the result should
be EPERM, but only MacOS implements that behavior.  Paper over the
differences.  Also turn EACCESS into EPERM, to paper over Windows
differences.

Related to WebAssembly/WASI#852 and
WebAssembly/wasi-testsuite#137.

POSIX 2008 reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
wingo added a commit to wingo/wasmtime that referenced this pull request Dec 16, 2025
When attempting to unlink a directory, POSIX specifies the result should
be EPERM, but only MacOS implements that behavior.  Paper over the
differences.  Also turn EACCESS into EPERM, to paper over Windows
differences.

Related to WebAssembly/WASI#852 and
WebAssembly/wasi-testsuite#137.

POSIX 2008 reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
wingo added a commit to wingo/wasmtime that referenced this pull request Dec 16, 2025
When attempting to unlink a directory, POSIX specifies the result should
be EPERM, but only MacOS implements that behavior.  Paper over the
differences.  Also turn EACCESS into EPERM, to paper over Windows
differences.

Related to WebAssembly/WASI#852 and
WebAssembly/wasi-testsuite#137.

POSIX 2008 reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
@badeend
Copy link
Member

badeend commented Dec 16, 2025

If all major OS flavors return something different, then clearly POSIX is not the authoritative source here. Additionally, the page you referenced includes the footnote:

The standard developers reviewed TR 24715-2006 and noted that LSB-conforming implementations may return [EISDIR] instead of [EPERM] when unlinking a directory.

I personally don't see anything wrong with Linux' behavior of returning EISDIR; it is more to-the-point and precisely describes why it failed, instead of a catch-all EPERM.

@wingo
Copy link
Author

wingo commented Dec 17, 2025

Ah, thank you for that footnote, I missed it! And I do like Linux's return code! But if we want one semantics, EISDIR isn't it, as we can't translate results from other platforms without races.

Another option would be to relax WASI to allow but not require is-directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P-filesystem Proposal: wasi-filesystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants