Kernel: Rename the getpid() syscall to getprocid()
Now, we have one single system call to fetch all sorts of identifiers: PID, PPID, UID, GID; EUID, EGID, and more...
This commit is contained in:
parent
a9d3bdba6f
commit
52d391507d
@ -7,7 +7,7 @@
|
||||
#define SYS_sleep 2
|
||||
#define SYS_write 3
|
||||
#define SYS_paint 4
|
||||
#define SYS_getpid 5
|
||||
#define SYS_getprocid 5
|
||||
#define SYS_mmap 6
|
||||
#define SYS_munmap 7
|
||||
#define SYS_open 8
|
||||
@ -33,7 +33,7 @@ void sys_yield(Context* context);
|
||||
void sys_sleep(Context* context, uint64_t ms);
|
||||
void sys_write(Context* context, int fd, size_t size, const char* addr);
|
||||
void sys_paint(Context* context, uint64_t x, uint64_t y, uint64_t w, uint64_t h, uint64_t col);
|
||||
void sys_getpid(Context* context);
|
||||
void sys_getprocid(Context* context, int field);
|
||||
void sys_mmap(Context* context, void* address, size_t size, int prot);
|
||||
void sys_munmap(Context* context, void* address, size_t size);
|
||||
void sys_open(Context* context, const char* filename, int flags);
|
||||
|
@ -16,7 +16,7 @@ void Syscall::entry(Context* context)
|
||||
case SYS_sleep: sys_sleep(context, context->rdi); break;
|
||||
case SYS_write: sys_write(context, (int)context->rdi, context->rsi, (const char*)context->rdx); break;
|
||||
case SYS_paint: sys_paint(context, context->rdi, context->rsi, context->rdx, context->r10, context->r8); break;
|
||||
case SYS_getpid: sys_getpid(context); break;
|
||||
case SYS_getprocid: sys_getprocid(context, (int)context->rdi); break;
|
||||
case SYS_mmap: sys_mmap(context, (void*)context->rdi, context->rsi, (int)context->rdx); break;
|
||||
case SYS_munmap: sys_munmap(context, (void*)context->rdi, context->rsi); break;
|
||||
case SYS_open: sys_open(context, (const char*)context->rdi, (int)context->rsi); break;
|
||||
|
24
kernel/src/sys/id.cpp
Normal file
24
kernel/src/sys/id.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "errno.h"
|
||||
#include "thread/Scheduler.h"
|
||||
|
||||
#define ID_PID 0
|
||||
#define ID_PPID 1
|
||||
|
||||
void sys_getprocid(Context* context, int field)
|
||||
{
|
||||
if (field == ID_PID)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->id;
|
||||
return;
|
||||
}
|
||||
else if (field == ID_PPID)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->ppid;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
context->rax = -EINVAL;
|
||||
return;
|
||||
}
|
||||
}
|
@ -18,9 +18,4 @@ void sys_sleep(Context* context, uint64_t ms)
|
||||
task->task_sleep = ms;
|
||||
task->state = task->Sleeping;
|
||||
Scheduler::task_yield(context);
|
||||
}
|
||||
|
||||
void sys_getpid(Context* context)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->id;
|
||||
}
|
Loading…
Reference in New Issue
Block a user