Kernel/LibC: Add {get,set}pgrp()

This commit is contained in:
Bananymous 2023-08-22 11:36:33 +03:00
parent ccc61cb10c
commit 42b90ae76c
5 changed files with 26 additions and 0 deletions

View File

@ -79,6 +79,7 @@ namespace Kernel
BAN::ErrorOr<long> sys_setegid(gid_t);
BAN::ErrorOr<long> sys_setreuid(uid_t, uid_t);
BAN::ErrorOr<long> sys_setregid(gid_t, gid_t);
BAN::ErrorOr<long> sys_setpgrp();
BAN::ErrorOr<long> sys_getuid() const { return m_credentials.ruid(); }
BAN::ErrorOr<long> sys_getgid() const { return m_credentials.rgid(); }

View File

@ -1137,6 +1137,13 @@ namespace Kernel
return 0;
}
BAN::ErrorOr<long> Process::sys_setpgrp()
{
LockGuard _(m_lock);
m_pgrp = pid();
return pgrp();
}
BAN::ErrorOr<BAN::String> Process::absolute_path_of(BAN::StringView path) const
{
ASSERT(m_lock.is_locked());

View File

@ -173,6 +173,12 @@ namespace Kernel
case SYS_GET_PID:
ret = Process::current().pid();
break;
case SYS_GET_PGRP:
ret = Process::current().pgrp();
break;
case SYS_SET_PGRP:
ret = Process::current().sys_setpgrp();
break;
default:
dwarnln("Unknown syscall {}", syscall);
break;

View File

@ -48,6 +48,8 @@ __BEGIN_DECLS
#define SYS_SIGNAL_DONE 41
#define SYS_TCSETPGRP 42
#define SYS_GET_PID 43
#define SYS_GET_PGRP 44
#define SYS_SET_PGRP 45
__END_DECLS

View File

@ -208,6 +208,11 @@ gid_t getegid(void)
return syscall(SYS_GET_EGID);
}
pid_t getpgrp(void)
{
return syscall(SYS_GET_PGRP);
}
int seteuid(uid_t uid)
{
return syscall(SYS_SET_EUID, uid);
@ -238,6 +243,11 @@ int setregid(gid_t rgid, gid_t egid)
return syscall(SYS_SET_REGID, rgid, egid);
}
pid_t setpgrp(void)
{
return syscall(SYS_SET_PGRP);
}
int tcsetpgrp(int fildes, pid_t pgid_id)
{
return syscall(SYS_TCSETPGRP, fildes, pgid_id);