mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:27:34 +00:00
Add getgid() and getpid() syscalls. Prep for LibC.
This commit is contained in:
parent
bae59609e3
commit
85bcf2ed0f
5 changed files with 34 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef SERENITY_KERNEL
|
#if defined(SERENITY_KERNEL) || defined(SERENITY_LIBC)
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
typedef unsigned short word;
|
typedef unsigned short word;
|
||||||
typedef unsigned int dword;
|
typedef unsigned int dword;
|
||||||
|
|
|
@ -77,6 +77,10 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3)
|
||||||
return current->sys$kill((pid_t)arg1, (int)arg2);
|
return current->sys$kill((pid_t)arg1, (int)arg2);
|
||||||
case Syscall::PosixGetuid:
|
case Syscall::PosixGetuid:
|
||||||
return current->sys$getuid();
|
return current->sys$getuid();
|
||||||
|
case Syscall::PosixGetgid:
|
||||||
|
return current->sys$getgid();
|
||||||
|
case Syscall::PosixGetpid:
|
||||||
|
return current->sys$getpid();
|
||||||
case Syscall::PosixExit:
|
case Syscall::PosixExit:
|
||||||
current->sys$exit((int)arg1);
|
current->sys$exit((int)arg1);
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DO_SYSCALL_A0(function) Syscall::invoke((DWORD)(function))
|
#include <AK/Types.h>
|
||||||
#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_A0(function) Syscall::invoke((dword)(function))
|
||||||
#define DO_SYSCALL_A3(function, arg1, arg2, arg3) Syscall::invoke((DWORD)(function), (DWORD)(arg1), (DWORD)(arg2), (DWORD)arg3)
|
#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 {
|
namespace Syscall {
|
||||||
|
|
||||||
|
@ -18,34 +20,36 @@ enum Function {
|
||||||
PosixKill = 0x1989,
|
PosixKill = 0x1989,
|
||||||
PosixGetuid = 0x1990,
|
PosixGetuid = 0x1990,
|
||||||
PosixExit = 0x1991,
|
PosixExit = 0x1991,
|
||||||
|
PosixGetgid = 0x1992,
|
||||||
|
PosixGetpid = 0x1993,
|
||||||
};
|
};
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
inline DWORD invoke(DWORD function)
|
inline dword invoke(dword function)
|
||||||
{
|
{
|
||||||
DWORD result;
|
dword result;
|
||||||
asm volatile("int $0x80":"=a"(result):"a"(function));
|
asm volatile("int $0x80":"=a"(result):"a"(function));
|
||||||
return result;
|
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));
|
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1));
|
||||||
return result;
|
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));
|
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2));
|
||||||
return result;
|
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));
|
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2),"b"(arg3));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,6 +551,16 @@ uid_t Task::sys$getuid()
|
||||||
return m_uid;
|
return m_uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gid_t Task::sys$getgid()
|
||||||
|
{
|
||||||
|
return m_gid;
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t Task::sys$getpid()
|
||||||
|
{
|
||||||
|
return m_pid;
|
||||||
|
}
|
||||||
|
|
||||||
bool Task::acceptsMessageFrom(Task& peer)
|
bool Task::acceptsMessageFrom(Task& peer)
|
||||||
{
|
{
|
||||||
return !ipc.msg.isValid() && (ipc.src == IPC::Handle::Any || ipc.src == peer.handle());
|
return !ipc.msg.isValid() && (ipc.src == IPC::Handle::Any || ipc.src == peer.handle());
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
void setState(State s) { m_state = s; }
|
void setState(State s) { m_state = s; }
|
||||||
|
|
||||||
uid_t sys$getuid();
|
uid_t sys$getuid();
|
||||||
|
gid_t sys$getgid();
|
||||||
|
pid_t sys$getpid();
|
||||||
int sys$open(const char* path, size_t pathLength);
|
int sys$open(const char* path, size_t pathLength);
|
||||||
int sys$close(int fd);
|
int sys$close(int fd);
|
||||||
int sys$read(int fd, void* outbuf, size_t nread);
|
int sys$read(int fd, void* outbuf, size_t nread);
|
||||||
|
@ -118,6 +120,7 @@ private:
|
||||||
void (*m_entry)() { nullptr };
|
void (*m_entry)() { nullptr };
|
||||||
pid_t m_pid { 0 };
|
pid_t m_pid { 0 };
|
||||||
uid_t m_uid { 0 };
|
uid_t m_uid { 0 };
|
||||||
|
gid_t m_gid { 0 };
|
||||||
DWORD m_ticks { 0 };
|
DWORD m_ticks { 0 };
|
||||||
DWORD m_ticksLeft { 0 };
|
DWORD m_ticksLeft { 0 };
|
||||||
IPC::Handle m_handle { 0 };
|
IPC::Handle m_handle { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue