Stream: git-wasmtime

Topic: wasmtime / issue #1935 Proposal: add right FD_READ to dir...


view this post on Zulip Wasmtime GitHub notifications bot (May 28 2026 at 02:53):

alexcrichton closed issue #1935:

This proposal tackles a situation where, given some directory handle, the user tries to open a subdirectory as a file, and invokes fd_read on the obtained WASI handle. This way, even though they obtained a valid handle from the path_open call (we don't have a way to tell the runtime to fail if the specified subpath is not a file; we can only fail if the subpath is not a directory and we specified the oflag O_DIRECTORY), the fd_read call will fail with ENOTCAPABLE errno since we don't include FD_READ right on directory handles when spawning them. In general, returning ENOTCAPABLE is fine, however, it doesn't match the common (expected?) behaviour of returning EISDIR in this case. Although, having said that, POSIX prescribes we should return EPERM rather than EISDIR. However, it seems that the Linux way of returning EISDIR is treated as standard. @sunfishcode please feel free to correct me here!

@sunfishcode and I had a discussion offline about this, and we both believe it would be reasonable to return EISDIR in this case in WASI as well. To achieve this, we would need to add FD_READ right to directory handles, and in the fd_read and fd_pread calls always return EISDIR errno. Having FD_READ right on the handle would prevent the implementation from failing with ENOTCAPABLE when verifying required rights on the handle.

I've decided to submit an issue about this first before rolling out a PR so that we can all agree if this is the right approach to the presented problem or not. The proposal if lands will introduce a breaking change to the end-user's code in that the expected errno values will change for the chain of syscalls described above.

view this post on Zulip Wasmtime GitHub notifications bot (May 28 2026 at 02:53):

alexcrichton commented on issue #1935:

Nowadays wasi-common, and rights in general, are on the way out so I'm going to close this.


Last updated: Jun 01 2026 at 09:49 UTC