I was using wasi::path_open on an existing file with the wasi::OFLAGS_EXCL
oflag parameter, which should return an error if the file exists.
When I run the program with wasmtime
, it returned Ok()
, which I suppose not correct, right ?
I tried it with wasmer
and it returned wasi::ERRNO_EXIST
as I think it should.
Here is the code I used here
Is this a bug in wasmtime, or I am missing something here ?
It indeed sounds like a bug in wasmtime.
It looks like your test isn't setting OFLAGS_CREAT
.
I don't know about WASI, but POSIX requires both flags for that behavior.
Indeed that appears to be what cap-std-sync
expects: https://github.com/bytecodealliance/wasmtime/blob/fa36e86f2c45f427e9d8a16f559a2515213ab3d4/crates/wasi-common/cap-std-sync/src/dir.rs#L32-L34
Oh, good spot. Yes, WASI should follow POSIX in this aspect.
Interesting. I also searched for POSIX and found here in O_EXCL
: If O_EXCL is set and O_CREAT is not set, the result is undefined.
So, it is undefined anyway and no behaviour specified.
Last updated: Nov 22 2024 at 17:03 UTC