aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKetan Reynolds <ketan.cs.reynolds@gmail.com>2024-05-01 21:00:33 +0200
committerRyan Liptak <squeek502@hotmail.com>2024-07-28 19:01:55 -0700
commitb4e7b6fdba2e4e212f8fa1e258ab6e869691baf0 (patch)
treeb30beddfc3929e0747ad87c26254196ff09b0d80 /lib
parentc15755092821c5c27727ebf416689084eab5b73e (diff)
downloadzig-b4e7b6fdba2e4e212f8fa1e258ab6e869691baf0.tar.gz
zig-b4e7b6fdba2e4e212f8fa1e258ab6e869691baf0.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/posix.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
index 3028deb91a..fafdf885e2 100644
--- a/lib/std/posix.zig
+++ b/lib/std/posix.zig
@@ -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,
@@ -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,
@@ -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,