wingo opened issue #11607:
Consider this test for an open
Descriptoron a directory,dirfd:assert_eq!(dirfd.create_directory_at("".to_string()).await, Err(ErrorCode::Invalid));I think
Invalidis the right error. However instead the error isNoEntry, which corresponds to thisstatxdocumentation:ENOENT A component of pathname does not exist, or pathname is an empty string and AT_EMPTY_PATH was not specified in flags.I think that these "at" WASI interfaces should instead avoid syscalling for
"", and instead returnInvalid.
wingo added the bug label to Issue #11607.
wingo edited issue #11607:
Consider this test for an open
Descriptoron a directory,dirfd:assert_eq!(dirfd.create_directory_at("".to_string()).await, Err(ErrorCode::Invalid));I think
Invalidis the right error. However instead the error isNoEntry, which corresponds to thisstatxdocumentation:ENOENT A component of pathname does not exist, or pathname is an empty string and AT_EMPTY_PATH was not specified in flags.I think that these "at" WASI interfaces should instead avoid syscalling for
"", and instead returnInvalid.
wingo commented on issue #11607:
Same issue for
stat-at(""),open-at(""),readlink-at(""),remove-directory-at(""), possibly others.
wingo commented on issue #11607:
For me the solution probably goes through something like https://github.com/bytecodealliance/wasmtime/issues/11524#issuecomment-3253843726.
wingo edited a comment on issue #11607:
Same issue for
stat-at(""),open-at(""),readlink-at(""),remove-directory-at(""),metadata-hash-at(""), possibly others.
alexcrichton added the wasi:impl label to Issue #11607.
alexcrichton added the wasi label to Issue #11607.
sunfishcode commented on issue #11607:
What would be the motivation for returning
Invalidhere?wasi-filesystem is unfortunately not an advantageous place to have novel opinions about how filesystem APIs should work, because it is constrained by compatibility requirements with underlying host implementations on one side, and in the expectations of applications on the other. If Linux returns
ENOENTforstatxandopenatand friends when given empty strings, then that makes it more likely to be compatible with existing applications thanEINVAL.
wingo commented on issue #11607:
NoEntryto me implies an error originating in the filesystem: some component leading up to the leaf is not present. However here we have no leaf and in fact no path, and because we don't expose anAT_EMPTY_PATHinterface, passing""is simply invalid. If you were designing it today,Invalidis the right return.I am sympathetic to the compatibility concern but I think that's more a wasi-libc question; in this case, wasmtime is fabricating the
ENOENT, it does not come from the kernel.
sunfishcode commented on issue #11607:
If we use
Invalidhere, and wish wasi-libc to translate it toENOENT, then wasi-libc would need to be able to distinguish anInvalidthat was caused by an empty path string from anInvalidwith any other cause. I suppose that's doable, but it seems awkward to have it redo the error checking the host does.
wingo commented on issue #11607:
Ah, true. I guess the question is, do you want wasi-libc to translate to
ENOENT? I didn't think that would be necessary, but I can see the value of wasi-filesystem being as close to POSIX as possible if the goal is to have the thinnest wasi-libc.You know what, thank you for humoring me here, but posix
mkdiratspecifiesENOENTfor empty-string, so I think I am just barking up the wrong tree: https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/functions/mkdir.html. Propose to close this bug as invalid.
Last updated: Dec 06 2025 at 06:05 UTC