fix(platform/linux): use FACCESSAT to implement access(2)

`ACCESS` syscall is not available on aarch64.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2025-12-01 14:41:52 +11:00
parent 90963fdfb9
commit 6d68ca9957
+6
View File
@@ -79,10 +79,16 @@ impl Sys {
}
impl Pal for Sys {
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
fn access(path: CStr, mode: c_int) -> Result<()> {
e_raw(unsafe { syscall!(ACCESS, path.as_ptr(), mode) }).map(|_| ())
}
#[cfg(target_arch = "aarch64")]
fn access(path: CStr, mode: c_int) -> Result<()> {
e_raw(unsafe { syscall!(FACCESSAT, AT_FDCWD, path.as_ptr(), mode, 0) }).map(|_| ())
}
unsafe fn brk(addr: *mut c_void) -> Result<*mut c_void> {
Ok(e_raw(unsafe { syscall!(BRK, addr) })? as *mut c_void)
}