mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
syscalls: setpriority
This commit is contained in:
@@ -103,6 +103,7 @@ extern syscall_fstatvfs
|
||||
extern syscall_fstatvfsat
|
||||
extern syscall_getsockopt
|
||||
extern syscall_clock_getres
|
||||
extern syscall_setpriority
|
||||
syscalltab:
|
||||
dq syscall_print
|
||||
dq syscall_mmap
|
||||
@@ -208,7 +209,8 @@ dq syscall_fstatvfs
|
||||
dq syscall_fstatvfsat
|
||||
dq syscall_getsockopt
|
||||
dq syscall_clock_getres
|
||||
syscallcount equ 104
|
||||
dq syscall_setpriority
|
||||
syscallcount equ 105
|
||||
section .text
|
||||
global arch_syscall_entry
|
||||
; on entry:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
void arch_interrupt_disable();
|
||||
void arch_interrupt_enable();
|
||||
|
||||
#define SYSCALL_COUNT 104
|
||||
#define SYSCALL_COUNT 105
|
||||
#define LOGSTR(x) arch_e9_puts(x)
|
||||
|
||||
static char *name[] = {
|
||||
@@ -117,6 +117,7 @@ static char *name[] = {
|
||||
"fstatvfsat",
|
||||
"getsockopt",
|
||||
"clock_getres",
|
||||
"setpriority",
|
||||
};
|
||||
|
||||
static char *args[] = {
|
||||
@@ -224,6 +225,7 @@ static char *args[] = {
|
||||
"dirfd %d path %s ustat %p flags %d", // fstatvfsat
|
||||
"fd %d level %d optname %d optval %p optlen %p", // getsockopt
|
||||
"clockid %d timespec %p", // clock_getres
|
||||
"which %d who %d prio %d", // setpriority
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <kernel/thread.h>
|
||||
#include <kernel/auth.h>
|
||||
#include <arch/cpu.h>
|
||||
|
||||
syscallret_t syscall_setpriority(context_t *, int which, int who, int priority) {
|
||||
syscallret_t ret = {
|
||||
.ret = -1
|
||||
};
|
||||
|
||||
if (which != 0) {
|
||||
ret.errno = EINVAL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (who) {
|
||||
ret.errno = ESRCH;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.errno = priority < current_thread()->proc->nice ? auth_process_check(¤t_thread()->proc->cred, AUTH_ACTIONS_PROCESS_NICE, NULL) : 0;
|
||||
if (ret.errno)
|
||||
return ret;
|
||||
|
||||
current_thread()->proc->nice = max(min(priority, SCHED_NICE_MAX), SCHED_NICE_MIN);
|
||||
|
||||
ret.ret = 0;
|
||||
return ret;
|
||||
}
|
||||
@@ -388,7 +388,7 @@ index ba9a520..b958ef3 100644
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
-
|
||||
diff --git mlibc-clean/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
index 3b04372..028fa48 100644
|
||||
index 3b04372..e5741d1 100644
|
||||
--- mlibc-clean/sysdeps/astral/generic/generic.cpp
|
||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
@@ -1,7 +1,9 @@
|
||||
@@ -818,8 +818,20 @@ index 3b04372..028fa48 100644
|
||||
int Sysdeps<Readv>::operator()(int fd, const struct iovec *iovs, int iovc, ssize_t *bytes_read) {
|
||||
long r;
|
||||
int error = syscall(SYSCALL_READV, &r, fd, (uint64_t)iovs, iovc);
|
||||
@@ -444,6 +827,12 @@ namespace mlibc {
|
||||
return ret;
|
||||
@@ -86,6 +469,11 @@ namespace mlibc {
|
||||
return e;
|
||||
}
|
||||
|
||||
+ int Sysdeps<SetPriority>::operator()(int which, id_t who, int prio) {
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_SETPRIORITY, &ret, which, who, prio);
|
||||
+ }
|
||||
+
|
||||
int Sysdeps<Shutdown>::operator()(int sockfd, int how) {
|
||||
long ret;
|
||||
return syscall(SYSCALL_SHUTDOWN, &ret, sockfd, how);
|
||||
@@ -487,8 +875,15 @@ namespace mlibc {
|
||||
return err;
|
||||
}
|
||||
|
||||
+ int Sysdeps<ThreadSetname>::operator()(void *tcb, const char *name) {
|
||||
@@ -828,18 +840,13 @@ index 3b04372..028fa48 100644
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
#ifndef MLIBC_BUILDING_RTLD
|
||||
|
||||
[[noreturn]] void Sysdeps<ThreadExit>::operator()() {
|
||||
@@ -489,6 +878,7 @@ namespace mlibc {
|
||||
|
||||
int Sysdeps<SetSockopt>::operator()(int fd, int layer, int number, const void *buffer, socklen_t size) {
|
||||
long ret;
|
||||
+ mlibc::infoLogger() << "setsockopt: fd " << fd << " layer " << layer << " number " << number << frg::endlog;
|
||||
return syscall(SYSCALL_SETSOCKOPT, &ret, fd, layer, number, (uint64_t)buffer, size);
|
||||
}
|
||||
|
||||
@@ -511,6 +901,11 @@ namespace mlibc {
|
||||
@@ -511,6 +906,11 @@ namespace mlibc {
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -851,7 +858,7 @@ index 3b04372..028fa48 100644
|
||||
int Sysdeps<Renameat>::operator()(int olddirfd, const char *old_path, int newdirfd, const char *new_path) {
|
||||
long ret;
|
||||
return syscall(SYSCALL_RENAMEAT, &ret, olddirfd, (uint64_t)old_path, newdirfd, (uint64_t)new_path);
|
||||
@@ -562,6 +957,16 @@ namespace mlibc {
|
||||
@@ -562,6 +962,16 @@ namespace mlibc {
|
||||
return sysdep<Ioctl>(fd, TCSETS, (void *)attr, &res);
|
||||
}
|
||||
|
||||
@@ -868,7 +875,7 @@ index 3b04372..028fa48 100644
|
||||
int Sysdeps<Poll>::operator()(struct pollfd *fds, nfds_t count, int timeout, int *num_events) {
|
||||
long ret;
|
||||
long error = syscall(SYSCALL_POLL, &ret, (uint64_t)fds, count, timeout);
|
||||
@@ -932,4 +1337,13 @@ namespace mlibc {
|
||||
@@ -932,4 +1342,13 @@ namespace mlibc {
|
||||
*nanos = ts.tv_nsec;
|
||||
return err;
|
||||
}
|
||||
@@ -905,10 +912,10 @@ index 7e4f2a1..ecc2677 100644
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git mlibc-clean/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
index a6c4067..f1e0b65 100644
|
||||
index a6c4067..fd38197 100644
|
||||
--- mlibc-clean/sysdeps/astral/include/astral/syscall.h
|
||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
@@ -103,6 +103,11 @@
|
||||
@@ -103,6 +103,12 @@
|
||||
#define SYSCALL_SYSINFO 96
|
||||
#define SYSCALL_WRITEV 97
|
||||
#define SYSCALL_READV 98
|
||||
@@ -917,11 +924,12 @@ index a6c4067..f1e0b65 100644
|
||||
+#define SYSCALL_FSTATVFSAT 101
|
||||
+#define SYSCALL_GETSOCKOPT 102
|
||||
+#define SYSCALL_CLOCK_GETRES 103
|
||||
+#define SYSCALL_SETPRIORITY 104
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
diff --git mlibc-clean/sysdeps/astral/include/mlibc/sysdeps.hpp mlibc-workdir/sysdeps/astral/include/mlibc/sysdeps.hpp
|
||||
index ce91084..5e96961 100644
|
||||
index ce91084..0fffdf3 100644
|
||||
--- mlibc-clean/sysdeps/astral/include/mlibc/sysdeps.hpp
|
||||
+++ mlibc-workdir/sysdeps/astral/include/mlibc/sysdeps.hpp
|
||||
@@ -7,8 +7,30 @@ namespace mlibc {
|
||||
@@ -980,14 +988,17 @@ index ce91084..5e96961 100644
|
||||
Poll,
|
||||
Ppoll,
|
||||
Pselect,
|
||||
@@ -135,6 +161,7 @@ struct AstralSysdepTags :
|
||||
@@ -135,7 +161,9 @@ struct AstralSysdepTags :
|
||||
VmUnmap,
|
||||
Isatty,
|
||||
ClockGet,
|
||||
- PrepareStack
|
||||
+ ClockGetres,
|
||||
PrepareStack
|
||||
+ PrepareStack,
|
||||
+ SetPriority
|
||||
{};
|
||||
|
||||
template<typename Tag>
|
||||
diff --git mlibc-clean/sysdeps/linux/generic/sysdeps.cpp mlibc-workdir/sysdeps/linux/generic/sysdeps.cpp
|
||||
index a07ed53..1474470 100644
|
||||
--- mlibc-clean/sysdeps/linux/generic/sysdeps.cpp
|
||||
|
||||
Reference in New Issue
Block a user