Stream: wasi

Topic: ✔ NOTCAPABLE vs ACCES error


view this post on Zulip Mohamed Abdelfatah (Aug 09 2022 at 09:23):

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!

WebAssembly System Interface. Contribute to WebAssembly/WASI development by creating an account on GitHub.

view this post on Zulip Dan Gohman (Aug 09 2022 at 12:53):

NOTCAPABLE came from CloudABI, and within WASI, it has been widely found to not be worthwhile, so we're working on phasing it out.

view this post on Zulip Dan Gohman (Aug 09 2022 at 12:54):

Going by POSIX, a read on an unreadable file descriptor (eg. opened without O_READ) should be BADF.

view this post on Zulip Dan Gohman (Aug 09 2022 at 12:55):

Can you say where you're seeing NOTCAPABLE?

view this post on Zulip Mohamed Abdelfatah (Aug 09 2022 at 16:16):

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.

A standalone runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip Dan Gohman (Aug 09 2022 at 19:33):

Thanks! I'll look into fixing that.

view this post on Zulip Dan Gohman (Aug 09 2022 at 20:33):

I've now filed https://github.com/bytecodealliance/wasmtime/pull/4666 to fix it.

ENOTCAPABLE was an error code that is used as part of the rights system, from CloudABI. There is a set of flags associated with each file descriptor listing which operations can be performed with t...

view this post on Zulip Mohamed Abdelfatah (Aug 10 2022 at 08:45):

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 ?

view this post on Zulip Dan Gohman (Aug 10 2022 at 10:57):

POSIX has nothing analogous to RIGHTS_FD_DATASYNC, so there's no obvous answer here.

view this post on Zulip Dan Gohman (Aug 10 2022 at 11:04):

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.

view this post on Zulip Mohamed Abdelfatah (Aug 10 2022 at 11:24):

Great. Thanks for the clarification!

view this post on Zulip Notification Bot (Aug 13 2022 at 17:15):

Mohamed Abdelfatah has marked this topic as resolved.


Last updated: Dec 23 2024 at 12:05 UTC