authorgravatar for hawkbee@gmail.comQun He <hawkbee@gmail.com> 2025-08-25 09:38:44+08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-25 11:27:59-07:00
loga7769e25beaf928b44449bd3746b3eb326255687
treec11933e50415f4a5f096ba92705bb94b0a89085d
parent5a0cf217756491169579b301a676a655b04f489b

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