Open squeek502 opened 3 weeks ago
My current thinking is that we might want to just lump all of these sort of "bad filename" related errors together and let the user attempt to sort it out, e.g. translate both
INVAL
andILSEQ
to something likeerror.BadPathName
and then have a doc comment that lays out all the possible ways it can be returned on the various platforms
This seems reasonable to me.
POSIX.1-2024
has addedEILSEQ
as an error for most filesystem-related functions with the description:and added a note in the RATIONALE section:
(see mkdir for one example, full list of affected funtions available here and that article also talks more about this change here)
This is an application of "Austin Group Defect 251" (https://www.austingroupbugs.net/view.php?id=251) and is a break from the previous 'file paths are just an arbitrary sequences of bytes (minus NUL)' stance
This is relevant to Zig in a few ways:
EINVAL
if the underlying filesystem doesn't support the filename (e.g.|
onvfat
), which Zig doesn't handle correctly yeterror.InvalidUtf8
because WASI defines filenames to be valid UTF-8 and returns ILSEQ when a filename is not valid UTF-8EILSEQ
was previously not a documented possible error for the relevant POSIX APIs, soILSEQ
was assumed to be a WASI-specific returnWith (2), this means that we will no longer be able to distinguish between "invalid UTF-8" or "contains newline" on WASI by the error code alone, so
.ILSEQ => return error.InvalidUtf8
will no longer be an advisable way to handleILSEQ
in WASI-specific code pathsMy current thinking is that we might want to just lump all of these sort of "bad filename" related errors together and let the user attempt to sort it out, e.g. translate both
INVAL
andILSEQ
to something likeerror.BadPathName
and then have a doc comment that lays out all the possible ways it can be returned on the various platformsThis is almost a duplicate of https://github.com/ziglang/zig/issues/15607, but I thought it might be worth tracking separately so I'm making an issue for it.