Can someone explain to me the difference between NOTCAPABLE and ACCES Errors ?
For example, When I tried to invoke fd_read on an fd
that doesn't have fd_read
base rights, wasmtime returned ERRNO_NOTCAPABLE
. I was confused since I though it should be ERRNO_ACCES
. Can someone explain to me why NOTCAPABLE
and not ACCES
?
Thank you!
NOTCAPABLE
came from CloudABI, and within WASI, it has been widely found to not be worthwhile, so we're working on phasing it out.
Going by POSIX, a read
on an unreadable file descriptor (eg. opened without O_READ
) should be BADF
.
Can you say where you're seeing NOTCAPABLE
?
Dan Gohman said:
Can you say where you're seeing
NOTCAPABLE
?
At first, I saw it here in the wasi-tests
in wasmtime. The test makes sure that the error returned is wasi::ERRNO_NOTCAPABLE
. I tried it also in a simple program on my machine and I found that indeed wasmtime
returns ERRNO_NOTCAPABLE
for any fd
that doesn't have RIGHTS_FD_READ
.
Thanks! I'll look into fixing that.
I've now filed https://github.com/bytecodealliance/wasmtime/pull/4666 to fix it.
Should the BADF
error be generalised for any operation performed on an fd
that doesn't have the right to ?
e.g. I tried to call fd_datasync
on an fd
that doesn't have RIGHTS_FD_DATASYNC
and the error returned was also ERRNO_NOTCAPABLE
. Should it also be BADF
?
POSIX has nothing analogous to RIGHTS_FD_DATASYNC
, so there's no obvous answer here.
More broadly, WASI is moving away from the rights system. The ability to control eg. fdatasync
separately from other operations isn't needed for POSIX compatibility, and isn't often needed, and when it is, users will be able to implement it using an intermediary.
Great. Thanks for the clarification!
Mohamed Abdelfatah has marked this topic as resolved.
Last updated: Dec 23 2024 at 12:05 UTC