Skip to content

Commit 38af49a

Browse files
tealsnowandrewrk
authored andcommitted
std.posix: handle INVAL in openZ and openatZ
Contributes to ziglang#15607 Although the case is not handled in `openatWasi` (as I could not get a working wasi environment to test the change) I have added a FIXME addressing it and linking to the issue.
1 parent c746d7a commit 38af49a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/std/posix.zig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t {
15981598
.INTR => continue,
15991599

16001600
.FAULT => unreachable,
1601-
.INVAL => unreachable,
1601+
.INVAL => return error.BadPathName,
16021602
.ACCES => return error.AccessDenied,
16031603
.FBIG => return error.FileTooBig,
16041604
.OVERFLOW => return error.FileTooBig,
@@ -1676,6 +1676,9 @@ pub fn openatWasi(
16761676
.INTR => continue,
16771677

16781678
.FAULT => unreachable,
1679+
// FIXME: It is worth looking into returning a `error.BadPathName`
1680+
// here if wasi follows other posix behavior
1681+
// see: https://github.com/ziglang/zig/issues/15607
16791682
.INVAL => unreachable,
16801683
.BADF => unreachable,
16811684
.ACCES => return error.AccessDenied,
@@ -1767,7 +1770,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) O
17671770
.INTR => continue,
17681771

17691772
.FAULT => unreachable,
1770-
.INVAL => unreachable,
1773+
.INVAL => return error.BadPathName,
17711774
.BADF => unreachable,
17721775
.ACCES => return error.AccessDenied,
17731776
.FBIG => return error.FileTooBig,

0 commit comments

Comments
 (0)