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.
This commit is contained in:
Qun He 2025-08-25 09:38:44 +08:00 committed by Alex Rønne Petersen
parent 6f07cc95d0
commit caa89c7601
No known key found for this signature in database

View File

@ -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);
}