The wasi crate has the sock_send and sock_recv functions, both of which takes in a file descriptor as an argument.
How do you get a file descriptor into WASI? I heard about passing file descriptors through Unix domain sockets, but doesn’t that require WASI to bind to a Unix socket first? I couldn’t find any functions for that
You can use --tcplisten or --listenfd:
https://github.com/bytecodealliance/wasmtime/pull/3729
Alsan Ali has marked this topic as resolved.
Hmm that seems to work for TCP. This will also probably work for Unix domain sockets by using --listenfd. But how do I use the Unix domain socket to pass file descriptors around? The "sendmsg" system call isn't there in the WASI crate.
I don't think that makes should be done at all. There is no direct mapping between wasi and host fds. Wasi fds may be backed by code running inside of wasmtime and as such those can't be sent to another process over a unix domain socket. Some fds received fron a unix domain socket may be dangerous and as such shouldn't be exposed to wasi.
I'd also be interested in this. I struggle to find examples of wasi+fs in general. Suggestions?
The WASI interface is still being developed. I've found the best canonical source of information is the wasmtime source code, especially https://docs.rs/wasmtime-wasi/latest/wasmtime_wasi/sync/struct.WasiCtxBuilder.html and the WasiCtx
it creates
Lann Martin said:
The WASI interface is still being developed. I've found the best canonical source of information is the wasmtime source code, especially https://docs.rs/wasmtime-wasi/latest/wasmtime_wasi/sync/struct.WasiCtxBuilder.html and the
WasiCtx
it creates
Yeah, been playing with that but have issues :). Ref: https://github.com/bytecodealliance/wasmtime/issues/4925
Last updated: Nov 22 2024 at 16:03 UTC