Skip to content

Commit 6e3fdb6

Browse files
committed
std.posix.faccessatZ: return error.UnsupportedFlags on too old linux versions
1 parent b433373 commit 6e3fdb6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/std/posix.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5056,7 +5056,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces
50565056
}
50575057

50585058
const flags_unsupported = switch (system) {
5059-
linux => builtin.abi.isAndroid() //standard android programs run in a seccomp sandbox that seems to trigger signal 31 (SIGSYS) for faccessat2
5059+
linux => (builtin.abi.isAndroid() //standard android programs run in a seccomp sandbox that seems to trigger signal 31 (SIGSYS) for faccessat2
5060+
or builtin.target.os.isAtLeast(.linux, .{ .major = 5, .minor = 8, .patch = 0 }) != true), //faccessat2 was introduced in Linux 5.8
50605061
else => false,
50615062
};
50625063
const need_flags = (flags != 0);
@@ -5086,6 +5087,10 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces
50865087
return error.InvalidUtf8
50875088
else
50885089
return unexpectedErrno(err),
5090+
.NOSYS => |err| if (system == linux)
5091+
return error.UnsupportedFlags
5092+
else
5093+
return unexpectedErrno(err),
50895094
else => |err| return unexpectedErrno(err),
50905095
}
50915096
}

0 commit comments

Comments
 (0)