mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
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:
parent
6f07cc95d0
commit
caa89c7601
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user