wasi-libc icon indicating copy to clipboard operation
wasi-libc copied to clipboard

why no dedicated __wasi_snapshot_preview1_fd_openat syscall?

Open trcrsired opened this issue 1 year ago • 2 comments

I just realized the open(2) is too complicated on wasm and even this syscall is too complicated https://github.com/trcrsired/wasi-libc/blob/c8352f8c145fe1fc21db79893f45ed7aa4d9eef2/libc-bottom-half/sources/__wasilibc_real.c#L437

There are no reasons to be so complicated tbh. Why no just a dedicated __wasi_snapshot_preview1_fd_openat syscall?

trcrsired avatar Dec 14 '23 09:12 trcrsired

https://github.com/WebAssembly/wasi-libc/blob/a796d874f8c47641c410746a3d4bd6a85d2baac2/libc-bottom-half/sources/preopens.c#L169 This is too complicated and not thread safe probably

trcrsired avatar Dec 14 '23 09:12 trcrsired

I just realized the open(2) is too complicated on wasm and even this syscall is too complicated https://github.com/trcrsired/wasi-libc/blob/c8352f8c145fe1fc21db79893f45ed7aa4d9eef2/libc-bottom-half/sources/__wasilibc_real.c#L437

There are no reasons to be so complicated tbh. Why no just a dedicated __wasi_snapshot_preview1_fd_openat syscall?

IIUC correctly __wasi_snapshot_preview1_path_open is effectively syscall_openat. Its first argument is a file descriptor which is non-optional. What preview1 does not have (by design) is syscall_open (without the fd argument).

sbc100 avatar Dec 14 '23 15:12 sbc100