From 40b6a9c5cc8537d017e4f316d28d8888db985141 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Wed, 7 Mar 2018 01:59:53 +0000 Subject: [PATCH] Finalize Aarch64 support Update platform support for linux to avoid the use of syscalls not supported by Aarch64. - link, chown, and open should use fchownat and linkat with fd set to AT_FDCWD. - use dup3 with the 3rd arg set to 0 instead of dup2. --- src/platform/src/linux/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/platform/src/linux/mod.rs b/src/platform/src/linux/mod.rs index 3dded49a57..bf6c18a1b5 100644 --- a/src/platform/src/linux/mod.rs +++ b/src/platform/src/linux/mod.rs @@ -18,7 +18,7 @@ pub fn chdir(path: *const c_char) -> c_int { } pub fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_int { - unsafe { syscall!(CHOWN, owner as u32, group as u32) as c_int } + unsafe { syscall!(FCHOWNAT, AT_FDCWD, path, owner as u32, group as u32) as c_int } } pub fn close(fildes: c_int) -> c_int { @@ -30,7 +30,7 @@ pub fn dup(fildes: c_int) -> c_int { } pub fn dup2(fildes: c_int, fildes2: c_int) -> c_int { - unsafe { syscall!(DUP2, fildes, fildes2) as c_int } + unsafe { syscall!(DUP3, fildes, fildes2, 0) as c_int } } pub fn exit(status: c_int) -> ! { @@ -92,15 +92,9 @@ pub fn getuid() -> uid_t { } pub fn link(path1: *const c_char, path2: *const c_char) -> c_int { - unsafe { syscall!(LINK, path1, path2) as c_int } + unsafe { syscall!(LINKAT, AT_FDCWD, path1, path2) as c_int } } -#[cfg(target_arch = "x86_64")] -pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { - unsafe { syscall!(OPEN, path, oflag, mode) as c_int } -} - -#[cfg(target_arch = "aarch64")] pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { unsafe { syscall!(OPENAT, AT_FDCWD, path, oflag, mode) as c_int } }