diff --git a/AK/Types.h b/AK/Types.h index ce92532e22..e0aaf808c5 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -1,6 +1,6 @@ #pragma once -#ifdef SERENITY_KERNEL +#if defined(SERENITY_KERNEL) || defined(SERENITY_LIBC) typedef unsigned char byte; typedef unsigned short word; typedef unsigned int dword; diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 63bea39db3..7ad1f2507d 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -77,6 +77,10 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3) return current->sys$kill((pid_t)arg1, (int)arg2); case Syscall::PosixGetuid: return current->sys$getuid(); + case Syscall::PosixGetgid: + return current->sys$getgid(); + case Syscall::PosixGetpid: + return current->sys$getpid(); case Syscall::PosixExit: current->sys$exit((int)arg1); ASSERT_NOT_REACHED(); diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 2188edd7bb..a11061e552 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -1,9 +1,11 @@ #pragma once -#define DO_SYSCALL_A0(function) Syscall::invoke((DWORD)(function)) -#define DO_SYSCALL_A1(function, arg1) Syscall::invoke((DWORD)(function), (DWORD)(arg1)) -#define DO_SYSCALL_A2(function, arg1, arg2) Syscall::invoke((DWORD)(function), (DWORD)(arg1), (DWORD)(arg2)) -#define DO_SYSCALL_A3(function, arg1, arg2, arg3) Syscall::invoke((DWORD)(function), (DWORD)(arg1), (DWORD)(arg2), (DWORD)arg3) +#include + +#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function)) +#define DO_SYSCALL_A1(function, arg1) Syscall::invoke((dword)(function), (dword)(arg1)) +#define DO_SYSCALL_A2(function, arg1, arg2) Syscall::invoke((dword)(function), (dword)(arg1), (dword)(arg2)) +#define DO_SYSCALL_A3(function, arg1, arg2, arg3) Syscall::invoke((dword)(function), (dword)(arg1), (dword)(arg2), (dword)arg3) namespace Syscall { @@ -18,34 +20,36 @@ enum Function { PosixKill = 0x1989, PosixGetuid = 0x1990, PosixExit = 0x1991, + PosixGetgid = 0x1992, + PosixGetpid = 0x1993, }; void initialize(); -inline DWORD invoke(DWORD function) +inline dword invoke(dword function) { - DWORD result; + dword result; asm volatile("int $0x80":"=a"(result):"a"(function)); return result; } -inline DWORD invoke(DWORD function, DWORD arg1) +inline dword invoke(dword function, dword arg1) { - DWORD result; + dword result; asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1)); return result; } -inline DWORD invoke(DWORD function, DWORD arg1, DWORD arg2) +inline dword invoke(dword function, dword arg1, dword arg2) { - DWORD result; + dword result; asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2)); return result; } -inline DWORD invoke(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3) +inline dword invoke(dword function, dword arg1, dword arg2, dword arg3) { - DWORD result; + dword result; asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2),"b"(arg3)); return result; } diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp index e46985ee4b..96b5508564 100644 --- a/Kernel/Task.cpp +++ b/Kernel/Task.cpp @@ -551,6 +551,16 @@ uid_t Task::sys$getuid() return m_uid; } +gid_t Task::sys$getgid() +{ + return m_gid; +} + +pid_t Task::sys$getpid() +{ + return m_pid; +} + bool Task::acceptsMessageFrom(Task& peer) { return !ipc.msg.isValid() && (ipc.src == IPC::Handle::Any || ipc.src == peer.handle()); diff --git a/Kernel/Task.h b/Kernel/Task.h index cd6a8968ef..eaf338b212 100644 --- a/Kernel/Task.h +++ b/Kernel/Task.h @@ -77,6 +77,8 @@ public: void setState(State s) { m_state = s; } uid_t sys$getuid(); + gid_t sys$getgid(); + pid_t sys$getpid(); int sys$open(const char* path, size_t pathLength); int sys$close(int fd); int sys$read(int fd, void* outbuf, size_t nread); @@ -118,6 +120,7 @@ private: void (*m_entry)() { nullptr }; pid_t m_pid { 0 }; uid_t m_uid { 0 }; + gid_t m_gid { 0 }; DWORD m_ticks { 0 }; DWORD m_ticksLeft { 0 }; IPC::Handle m_handle { 0 };