From 55c0eeaa795e54ef50825fb03784da9635bb0b85 Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Wed, 4 Nov 2015 14:38:54 +0100 Subject: [PATCH] Add sys_getppid() --- src/kernel/emulation/linux/CMakeLists.txt | 1 + src/kernel/emulation/linux/syscalls.c | 2 ++ src/kernel/emulation/linux/unistd/getppid.c | 16 ++++++++++++++++ src/kernel/emulation/linux/unistd/getppid.h | 7 +++++++ 4 files changed, 26 insertions(+) create mode 100644 src/kernel/emulation/linux/unistd/getppid.c create mode 100644 src/kernel/emulation/linux/unistd/getppid.h diff --git a/src/kernel/emulation/linux/CMakeLists.txt b/src/kernel/emulation/linux/CMakeLists.txt index 4d1c24d0a..80432d02a 100644 --- a/src/kernel/emulation/linux/CMakeLists.txt +++ b/src/kernel/emulation/linux/CMakeLists.txt @@ -55,6 +55,7 @@ set(emulation_sources unistd/umask.c unistd/chroot.c unistd/getgid.c + unistd/getppid.c process/vfork.c process/fork.c process/wait4.c diff --git a/src/kernel/emulation/linux/syscalls.c b/src/kernel/emulation/linux/syscalls.c index 6b89ffec3..a912cec03 100644 --- a/src/kernel/emulation/linux/syscalls.c +++ b/src/kernel/emulation/linux/syscalls.c @@ -41,6 +41,7 @@ #include "unistd/chmod.h" #include "unistd/chown.h" #include "unistd/getgid.h" +#include "unistd/getppid.h" #include "signal/kill.h" #include "signal/sigaltstack.h" #include "signal/sigaction.h" @@ -125,6 +126,7 @@ void* __bsd_syscall_table[512] = { [33] = sys_access, [36] = sys_sync, [37] = sys_kill, + [39] = sys_getppid, [41] = sys_dup, [43] = sys_getegid, [46] = sys_sigaction, diff --git a/src/kernel/emulation/linux/unistd/getppid.c b/src/kernel/emulation/linux/unistd/getppid.c new file mode 100644 index 000000000..42e559bd6 --- /dev/null +++ b/src/kernel/emulation/linux/unistd/getppid.c @@ -0,0 +1,16 @@ +#include "getppid.h" +#include "../base.h" +#include "../errno.h" +#include + +long sys_getppid(void) +{ + int ret; + + ret = LINUX_SYSCALL0(__NR_getppid); + if (ret < 0) + ret = errno_linux_to_bsd(ret); + + return ret; +} + diff --git a/src/kernel/emulation/linux/unistd/getppid.h b/src/kernel/emulation/linux/unistd/getppid.h new file mode 100644 index 000000000..1bd5fe2ab --- /dev/null +++ b/src/kernel/emulation/linux/unistd/getppid.h @@ -0,0 +1,7 @@ +#ifndef LINUX_GETPPID_H +#define LINUX_GETPPID_H + +long sys_getppid(void); + +#endif + -- 2.51.2