mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
syscalls: sigsuspend
This commit is contained in:
@@ -87,6 +87,7 @@ extern syscall_setuid
|
|||||||
extern syscall_seteuid
|
extern syscall_seteuid
|
||||||
extern syscall_setgid
|
extern syscall_setgid
|
||||||
extern syscall_setegid
|
extern syscall_setegid
|
||||||
|
extern syscall_sigsuspend
|
||||||
syscalltab:
|
syscalltab:
|
||||||
dq syscall_print
|
dq syscall_print
|
||||||
dq syscall_mmap
|
dq syscall_mmap
|
||||||
@@ -176,7 +177,8 @@ dq syscall_setuid
|
|||||||
dq syscall_seteuid
|
dq syscall_seteuid
|
||||||
dq syscall_setgid
|
dq syscall_setgid
|
||||||
dq syscall_setegid
|
dq syscall_setegid
|
||||||
syscallcount equ 88
|
dq syscall_sigsuspend
|
||||||
|
syscallcount equ 89
|
||||||
section .text
|
section .text
|
||||||
global arch_syscall_entry
|
global arch_syscall_entry
|
||||||
; on entry:
|
; on entry:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#ifdef SYSCALL_LOGGING
|
#ifdef SYSCALL_LOGGING
|
||||||
|
|
||||||
#define SYSCALL_COUNT 88
|
#define SYSCALL_COUNT 89
|
||||||
#define LOGSTR(x) arch_e9_puts(x)
|
#define LOGSTR(x) arch_e9_puts(x)
|
||||||
|
|
||||||
static char *name[] = {
|
static char *name[] = {
|
||||||
@@ -96,7 +96,8 @@ static char *name[] = {
|
|||||||
"setuid",
|
"setuid",
|
||||||
"seteuid",
|
"seteuid",
|
||||||
"setgid",
|
"setgid",
|
||||||
"setegid"
|
"setegid",
|
||||||
|
"sigsuspend"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *args[] = {
|
static char *args[] = {
|
||||||
@@ -187,7 +188,8 @@ static char *args[] = {
|
|||||||
"uid %d", // setuid
|
"uid %d", // setuid
|
||||||
"euid %d", // seteuid
|
"euid %d", // seteuid
|
||||||
"gid %d", // setgid
|
"gid %d", // setgid
|
||||||
"egid %d" // setegid
|
"egid %d", // setegid
|
||||||
|
"sigset %p" // sigsuspend
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include <kernel/syscalls.h>
|
||||||
|
#include <kernel/signal.h>
|
||||||
|
#include <logging.h>
|
||||||
|
|
||||||
|
syscallret_t syscall_sigsuspend(context_t *, sigset_t *umask) {
|
||||||
|
syscallret_t ret = {
|
||||||
|
.ret = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
sigset_t mask;
|
||||||
|
sigset_t old;
|
||||||
|
|
||||||
|
ret.errno = usercopy_fromuser(&mask, umask, sizeof(sigset_t));
|
||||||
|
if (ret.errno)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
signal_changemask(_cpu()->thread, SIG_SETMASK, &mask, &old);
|
||||||
|
|
||||||
|
sched_preparesleep(true);
|
||||||
|
__assert(sched_yield() == SCHED_WAKEUP_REASON_INTERRUPTED);
|
||||||
|
|
||||||
|
signal_changemask(_cpu()->thread, SIG_SETMASK, &old, NULL);
|
||||||
|
|
||||||
|
ret.errno = EINTR;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -219,10 +219,10 @@ index 0000000..e5b087a
|
|||||||
+
|
+
|
||||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..13f1f36
|
index 0000000..32711c2
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
@@ -0,0 +1,985 @@
|
@@ -0,0 +1,990 @@
|
||||||
+#include <bits/ensure.h>
|
+#include <bits/ensure.h>
|
||||||
+#include <mlibc/debug.hpp>
|
+#include <mlibc/debug.hpp>
|
||||||
+#include <mlibc/all-sysdeps.hpp>
|
+#include <mlibc/all-sysdeps.hpp>
|
||||||
@@ -297,6 +297,11 @@ index 0000000..13f1f36
|
|||||||
+ return 0;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ int sys_sigsuspend(const sigset_t *set) {
|
||||||
|
+ long ret;
|
||||||
|
+ return syscall(SYSCALL_SIGSUSPEND, &ret, (uint64_t)set);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ int sys_vm_protect(void *pointer, size_t size, int prot) {
|
+ int sys_vm_protect(void *pointer, size_t size, int prot) {
|
||||||
+ long ret;
|
+ long ret;
|
||||||
+ return syscall(SYSCALL_MPROTECT, &ret, (uint64_t)pointer, size, prot);
|
+ return syscall(SYSCALL_MPROTECT, &ret, (uint64_t)pointer, size, prot);
|
||||||
@@ -1227,10 +1232,10 @@ index 0000000..990eca0
|
|||||||
+#endif
|
+#endif
|
||||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..90516f7
|
index 0000000..7772e74
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
@@ -0,0 +1,111 @@
|
@@ -0,0 +1,112 @@
|
||||||
+#ifndef _SYSCALL_H_INCLUDE
|
+#ifndef _SYSCALL_H_INCLUDE
|
||||||
+#define _SYSCALL_H_INCLUDE
|
+#define _SYSCALL_H_INCLUDE
|
||||||
+
|
+
|
||||||
@@ -1322,6 +1327,7 @@ index 0000000..90516f7
|
|||||||
+#define SYSCALL_SETEUID 85
|
+#define SYSCALL_SETEUID 85
|
||||||
+#define SYSCALL_SETGID 86
|
+#define SYSCALL_SETGID 86
|
||||||
+#define SYSCALL_SETEGID 87
|
+#define SYSCALL_SETEGID 87
|
||||||
|
+#define SYSCALL_SIGSUSPEND 88
|
||||||
+
|
+
|
||||||
+#include <stddef.h>
|
+#include <stddef.h>
|
||||||
+#include <stdint.h>
|
+#include <stdint.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user