From 813a0f125e2619f0a056d675339cab6ce34a2cbf Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 30 Jul 2025 23:27:32 +0100 Subject: [PATCH] std.posix: Default ACCMODE to NONE for serenity Unlike all other platforms where RDONLY is 0 it does not work as a default for the O flags on serenity - various syscalls other than 'open', e.g. 'pipe', return EINVAL if unexpected bits are set in the flags. --- lib/std/c.zig | 2 +- lib/std/posix.zig | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index b9a659cae6..2339ede076 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -8604,7 +8604,7 @@ pub const O = switch (native_os) { }, // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L28-L43 .serenity => packed struct(c_int) { - ACCMODE: std.posix.ACCMODE = .RDONLY, + ACCMODE: std.posix.ACCMODE = .NONE, EXEC: bool = false, CREAT: bool = false, EXCL: bool = false, diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 54c6470d2c..e10023f6b1 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -204,6 +204,7 @@ pub const ACCMODE = switch (native_os) { // implements this suggestion. // https://github.com/SerenityOS/serenity/blob/4adc51fdf6af7d50679c48b39362e062f5a3b2cb/Kernel/API/POSIX/fcntl.h#L28-L30 .serenity => enum(u2) { + NONE = 0, RDONLY = 1, WRONLY = 2, RDWR = 3,