Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a more general __WASI_FILETYPE_SOCKET #4

Closed
kubkon opened this issue Aug 26, 2019 · 2 comments
Closed

Add a more general __WASI_FILETYPE_SOCKET #4

kubkon opened this issue Aug 26, 2019 · 2 comments

Comments

@kubkon
Copy link
Contributor

kubkon commented Aug 26, 2019

Currently, we have __WASI_FILETYPE_SOCKET_STREAM and __WASI_FILETYPE_SOCKET_DGRAM which seems to be a tad bit too specfic for calls such as fd_readdir. That is, when translating libc::dirent to __wasi_dirent_t, we are required to do custom mapping between libc::dirent::d_type to __wasi_dirent_t::__wasi_filetype_t, and it becomes convoluted and tricky to properly work out whether we are dealing with a socket stream or datagram. Why is that? Note that when performing an fd_readdir call in WASI, we pass in a descriptor to the directory only; we then receive libc::dirent structures one by one, and perform translation to __wasi_dirent_t. If the underlying "file" is a socket, we have no way of working out whether it's a stream or datagram without performing another syscall, i.e., getsockopt (libc::dirent::d_type only tells us that we're dealing with some sort of a socket).

My proposition here would be to create a more general WASI filetype, __WASI_FILETYPE_SOCKET, which would act as a catch-all for all socket types, and we would then burden the WASI client to actually perform another syscall to work out what type of socket they are actually dealing with.

@sunfishcode sunfishcode transferred this issue from WebAssembly/WASI May 20, 2020
@linclark
Copy link
Member

linclark commented Apr 2, 2021

[bookkeeping] Added to the Moving wasi-filesystem to Phase 3 project.

sunfishcode added a commit to sunfishcode/wasi-filesystem that referenced this issue Nov 22, 2021
This makes a number of changes, to make use of interface-types features such
as expected, variant types, and resources. The change to use resources in
particular means that filesystem functions are now methods of the descriptor
resource. Since this means renaming everything, take this opportunity to
introduce a new naming conventions, with _at being used for functions that
take dirfd+path arguments.

This also eliminates the rights concept what was present in earlier versions
of WASI, has has discussed in WebAssembly#31. This required adding new flags to open_at,
so while here, this also adds basic chmod-like support, as discussed in WebAssembly#33.

And, this removes support for readdir seeking (seekdir/telldir), as discussed
in WebAssembly#7.

And it adds a fifo file type and a more general socket type, as discussed in WebAssembly#4.
sunfishcode added a commit that referenced this issue Dec 15, 2021
This makes a number of changes, to make use of interface-types features such
as expected, variant types, and resources. The change to use resources in
particular means that filesystem functions are now methods of the descriptor
resource. Since this means renaming everything, take this opportunity to
introduce a new naming conventions, with _at being used for functions that
take dirfd+path arguments.

This also eliminates the rights concept what was present in earlier versions
of WASI, has has discussed in #31. This required adding new flags to open_at,
so while here, this also adds basic chmod-like support, as discussed in #33.

And, this removes support for readdir seeking (seekdir/telldir), as discussed
in #7.

And it adds a fifo file type and a more general socket type, as discussed in #4.
@sunfishcode
Copy link
Member

The current wasi-filesystem.wit.md now contains a socket in the type enum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants