mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Add getgid() and getpid() syscalls. Prep for LibC.
This commit is contained in:
parent
bae59609e3
commit
85bcf2ed0f
Notes:
sideshowbarker
2024-07-19 18:45:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/85bcf2ed0f0
5 changed files with 34 additions and 13 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 <AK/Types.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in a new issue