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;
|
||||
}
|
||||
Reference in New Issue
Block a user