From caa89c7601bba7520bae0e295cce1b7db896041c Mon Sep 17 00:00:00 2001 From: Qun He Date: Mon, 25 Aug 2025 09:38:44 +0800 Subject: [PATCH] os.linux: faccessat wrapper prefer to faccessat syscall when flags is zero. This make `fs.Dir.access` has compatibility like the zig version before. With this change the `zig build --search-prefix` command would work again like the zig 0.14 version when used on Ubuntu22.04, kernel version 5.4. --- lib/std/os/linux.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 1aa9ea2852..7db0634271 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1238,11 +1238,14 @@ pub fn access(path: [*:0]const u8, mode: u32) usize { if (@hasField(SYS, "access")) { return syscall2(.access, @intFromPtr(path), mode); } else { - return syscall4(.faccessat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), mode, 0); + return faccessat(AT.FDCWD, path, mode, 0); } } pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { + if (flags == 0) { + return syscall3(.faccessat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode); + } return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags); }