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_readon the obtained WASI handle. This way, even though they obtained a valid handle from thepath_opencall (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 oflagO_DIRECTORY), thefd_readcall will fail withENOTCAPABLEerrno since we don't includeFD_READright on directory handles when spawning them. In general, returningENOTCAPABLEis fine, however, it doesn't match the common (expected?) behaviour of returningEISDIRin this case. Although, having said that, POSIX prescribes we should returnEPERMrather thanEISDIR. However, it seems that the Linux way of returningEISDIRis 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
EISDIRin this case in WASI as well. To achieve this, we would need to addFD_READright to directory handles, and in thefd_readandfd_preadcalls always returnEISDIRerrno. HavingFD_READright on the handle would prevent the implementation from failing withENOTCAPABLEwhen 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.
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