mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Merge pull request #3476 from PucklaJ/syscall-fix
[sys/linux] Fix fork and execve syscalls on arm64
This commit is contained in:
@@ -1815,3 +1815,11 @@ EPoll_Ctl_Opcode :: enum i32 {
|
|||||||
DEL = 2,
|
DEL = 2,
|
||||||
MOD = 3,
|
MOD = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bits for execveat(2) flags.
|
||||||
|
*/
|
||||||
|
Execveat_Flags_Bits :: enum {
|
||||||
|
AT_SYMLINK_NOFOLLOW = 8,
|
||||||
|
AT_EMPTY_PATH = 12,
|
||||||
|
}
|
||||||
|
|||||||
@@ -749,17 +749,13 @@ getsockopt :: proc {
|
|||||||
getsockopt_base,
|
getsockopt_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(flysand): clone (probably not in this PR, maybe not ever)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates a copy of the running process.
|
Creates a copy of the running process.
|
||||||
Available since Linux 1.0.
|
Available since Linux 1.0.
|
||||||
*/
|
*/
|
||||||
fork :: proc "contextless" () -> (Pid, Errno) {
|
fork :: proc "contextless" () -> (Pid, Errno) {
|
||||||
when ODIN_ARCH == .arm64 {
|
when ODIN_ARCH == .arm64 {
|
||||||
// Note(flysand): this syscall is not documented, but the bottom 8 bits of flags
|
ret := syscall(SYS_clone, u64(Signal.SIGCHLD), cast(rawptr) nil, cast(rawptr) nil, cast(rawptr) nil, u64(0))
|
||||||
// are for exit signal
|
|
||||||
ret := syscall(SYS_clone, Signal.SIGCHLD)
|
|
||||||
return errno_unwrap(ret, Pid)
|
return errno_unwrap(ret, Pid)
|
||||||
} else {
|
} else {
|
||||||
ret := syscall(SYS_fork)
|
ret := syscall(SYS_fork)
|
||||||
@@ -789,7 +785,7 @@ execve :: proc "contextless" (name: cstring, argv: [^]cstring, envp: [^]cstring)
|
|||||||
ret := syscall(SYS_execve, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp)
|
ret := syscall(SYS_execve, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp)
|
||||||
return Errno(-ret)
|
return Errno(-ret)
|
||||||
} else {
|
} else {
|
||||||
ret := syscall(SYS_execveat, AT_FDCWD, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp)
|
ret := syscall(SYS_execveat, AT_FDCWD, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp, i32(0))
|
||||||
return Errno(-ret)
|
return Errno(-ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2818,7 +2814,7 @@ getrandom :: proc "contextless" (buf: []u8, flags: Get_Random_Flags) -> (int, Er
|
|||||||
Execute program relative to a directory file descriptor.
|
Execute program relative to a directory file descriptor.
|
||||||
Available since Linux 3.19.
|
Available since Linux 3.19.
|
||||||
*/
|
*/
|
||||||
execveat :: proc "contextless" (dirfd: Fd, name: cstring, argv: [^]cstring, envp: [^]cstring, flags: FD_Flags = {}) -> (Errno) {
|
execveat :: proc "contextless" (dirfd: Fd, name: cstring, argv: [^]cstring, envp: [^]cstring, flags: Execveat_Flags = {}) -> (Errno) {
|
||||||
ret := syscall(SYS_execveat, dirfd, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp, transmute(i32) flags)
|
ret := syscall(SYS_execveat, dirfd, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp, transmute(i32) flags)
|
||||||
return Errno(-ret)
|
return Errno(-ret)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1303,3 +1303,8 @@ EPoll_Event :: struct #packed {
|
|||||||
events: EPoll_Event_Kind,
|
events: EPoll_Event_Kind,
|
||||||
data: EPoll_Data,
|
data: EPoll_Data,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Flags for execveat(2) syscall.
|
||||||
|
*/
|
||||||
|
Execveat_Flags :: bit_set[Execveat_Flags_Bits; i32]
|
||||||
|
|||||||
Reference in New Issue
Block a user