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 {...@@ -1598,7 +1598,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t {
1598 .INTR => continue,1598 .INTR => continue,
15991599
1600 .FAULT => unreachable,1600 .FAULT => unreachable,
1601 .INVAL => unreachable,1601 .INVAL => return error.BadPathName,
1602 .ACCES => return error.AccessDenied,1602 .ACCES => return error.AccessDenied,
1603 .FBIG => return error.FileTooBig,1603 .FBIG => return error.FileTooBig,
1604 .OVERFLOW => return error.FileTooBig,1604 .OVERFLOW => return error.FileTooBig,
...@@ -1676,6 +1676,9 @@ pub fn openatWasi(...@@ -1676,6 +1676,9 @@ pub fn openatWasi(
1676 .INTR => continue,1676 .INTR => continue,
16771677
1678 .FAULT => unreachable,1678 .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
1679 .INVAL => unreachable,1682 .INVAL => unreachable,
1680 .BADF => unreachable,1683 .BADF => unreachable,
1681 .ACCES => return error.AccessDenied,1684 .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...@@ -1767,7 +1770,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) O
1767 .INTR => continue,1770 .INTR => continue,
17681771
1769 .FAULT => unreachable,1772 .FAULT => unreachable,
1770 .INVAL => unreachable,1773 .INVAL => return error.BadPathName,
1771 .BADF => unreachable,1774 .BADF => unreachable,
1772 .ACCES => return error.AccessDenied,1775 .ACCES => return error.AccessDenied,
1773 .FBIG => return error.FileTooBig,1776 .FBIG => return error.FileTooBig,