authorgravatar for ketan.cs.reynolds@gmail.comKetan Reynolds <ketan.cs.reynolds@gmail.com> 2024-05-01 21:00:33+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-07-28 19:01:55-07:00
logb4e7b6fdba2e4e212f8fa1e258ab6e869691baf0
treeb30beddfc3929e0747ad87c26254196ff09b0d80
parentc15755092821c5c27727ebf416689084eab5b73e

std.posix: handle INVAL in openZ and openatZ

Contributes to #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 files changed, 5 insertions(+), 2 deletions(-)

lib/std/posix.zig+5-2
......@@ -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,