Skip to content

Commit

Permalink
std.posix: handle INVAL in openZ and openatZ
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tealsnow authored and squeek502 committed Jul 29, 2024
1 parent c157550 commit b4e7b6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/std/posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t {
.INTR => continue,

.FAULT => unreachable,
.INVAL => unreachable,
.INVAL => return error.BadPathName,
.ACCES => return error.AccessDenied,
.FBIG => return error.FileTooBig,
.OVERFLOW => return error.FileTooBig,
Expand Down Expand Up @@ -1676,6 +1676,9 @@ pub fn openatWasi(
.INTR => continue,

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

.FAULT => unreachable,
.INVAL => unreachable,
.INVAL => return error.BadPathName,
.BADF => unreachable,
.ACCES => return error.AccessDenied,
.FBIG => return error.FileTooBig,
Expand Down

0 comments on commit b4e7b6f

Please sign in to comment.