kernel+libc: Implement getpgid()
This commit is contained in:
parent
d27ffce5db
commit
b64093dee5
@ -128,6 +128,20 @@ Result<u64> sys_setpgid(Registers*, SyscallArgs args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result<u64> sys_getpgid(Registers*, SyscallArgs args)
|
||||
{
|
||||
pid_t pid = (pid_t)args[0];
|
||||
|
||||
auto* current = Scheduler::current();
|
||||
if (pid == 0) pid = (pid_t)current->id;
|
||||
|
||||
if (pid < 0) return err(EINVAL);
|
||||
|
||||
auto* thread = TRY(Result<Thread*>::from_option(Scheduler::find_by_pid(pid), ESRCH));
|
||||
|
||||
return (u64)thread->pgid;
|
||||
}
|
||||
|
||||
Result<u64> sys_fchmodat(Registers*, SyscallArgs args)
|
||||
{
|
||||
int dirfd = (int)args[0];
|
||||
|
@ -45,6 +45,9 @@ extern "C"
|
||||
/* Return the current process' effective group ID. */
|
||||
gid_t getegid(void);
|
||||
|
||||
/* Return a process' process group ID. */
|
||||
pid_t getpgid(pid_t pid);
|
||||
|
||||
/* Set the current process' user IDs. */
|
||||
int setuid(uid_t uid);
|
||||
|
||||
|
@ -120,6 +120,12 @@ extern "C"
|
||||
return (gid_t)syscall(SYS_getegid);
|
||||
}
|
||||
|
||||
pid_t getpgid(pid_t pid)
|
||||
{
|
||||
long rc = syscall(SYS_getpgid, pid);
|
||||
__errno_return(rc, pid_t);
|
||||
}
|
||||
|
||||
int setuid(uid_t uid)
|
||||
{
|
||||
long rc = syscall(SYS_setuid, uid);
|
||||
|
@ -6,7 +6,8 @@
|
||||
_e(getgid) _e(getegid) _e(setuid) _e(setgid) _e(seteuid) _e(setegid) _e(fchmodat) _e(fchownat) _e(ioctl) \
|
||||
_e(fstatat) _e(chdir) _e(getcwd) _e(unlinkat) _e(uname) _e(sethostname) _e(dup2) _e(pipe) _e(mount) \
|
||||
_e(umount) _e(pstat) _e(getrusage) _e(symlinkat) _e(readlinkat) _e(umask) _e(linkat) _e(faccessat) \
|
||||
_e(pivot_root) _e(sigreturn) _e(sigaction) _e(kill) _e(sigprocmask) _e(setpgid) _e(isatty)
|
||||
_e(pivot_root) _e(sigreturn) _e(sigaction) _e(kill) _e(sigprocmask) _e(setpgid) _e(isatty) \
|
||||
_e(getpgid)
|
||||
|
||||
enum Syscalls
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user