authorgravatar for hawkbee@gmail.comQun He <hawkbee@gmail.com> 2025-08-25 09:38:44+08:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-26 00:11:43+02:00
logcaa89c7601bba7520bae0e295cce1b7db896041c
treef93d8f37adb3b1d33b4e36cd610f1e00f65f31c5
parent6f07cc95d0c17c7778b37eea646a20886bc7d34c
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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.

1 files changed, 4 insertions(+), 1 deletions(-)

lib/std/os/linux.zig+4-1
...@@ -1238,11 +1238,14 @@ pub fn access(path: [*:0]const u8, mode: u32) usize {...@@ -1238,11 +1238,14 @@ pub fn access(path: [*:0]const u8, mode: u32) usize {
1238 if (@hasField(SYS, "access")) {1238 if (@hasField(SYS, "access")) {
1239 return syscall2(.access, @intFromPtr(path), mode);1239 return syscall2(.access, @intFromPtr(path), mode);
1240 } else {1240 } else {
1241 return syscall4(.faccessat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), mode, 0);1241 return faccessat(AT.FDCWD, path, mode, 0);
1242 }1242 }
1243}1243}
12441244
1245pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {1245pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {
1246 if (flags == 0) {
1247 return syscall3(.faccessat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode);
1248 }
1246 return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags);1249 return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags);
1247}1250}
12481251