Skip to content
Snippets Groups Projects
Commit 40b6a9c5 authored by Dan Robertson's avatar Dan Robertson
Browse files

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.
parent 543526cb
No related branches found
No related tags found
1 merge request!18Finalize Aarch64 support
......@@ -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 }
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment