From c4ea2a195ca29a4833a9b70a7b6d17b0bca16341 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 2 Aug 2011 19:22:08 +0200 Subject: [PATCH] getsid() implementation --- common/include/minix/callnr.h | 4 +++- common/include/minix/com.h | 3 +++ lib/nbsd_libc/sys-minix/Makefile.inc | 2 +- lib/nbsd_libc/sys-minix/getsid.c | 14 ++++++++++++++ servers/pm/getset.c | 12 +++++++++++- servers/pm/table.c | 1 + servers/vfs/table.c | 1 + 7 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 lib/nbsd_libc/sys-minix/getsid.c diff --git a/common/include/minix/callnr.h b/common/include/minix/callnr.h index 9b58f0fbb..0236fcf04 100644 --- a/common/include/minix/callnr.h +++ b/common/include/minix/callnr.h @@ -1,4 +1,4 @@ -#define NCALLS 113 /* number of system calls allowed */ +#define NCALLS 114 /* number of system calls allowed */ #define EXIT 1 #define FORK 2 @@ -120,6 +120,8 @@ #define FSTAT 66 #define LSTAT 67 +#define PM_GETSID 113 /* PM getsid() */ + #define TASK_REPLY 121 /* to VFS: reply code from drivers, not * really a standalone call. */ diff --git a/common/include/minix/com.h b/common/include/minix/com.h index ca10ec6ae..342bd0ba1 100644 --- a/common/include/minix/com.h +++ b/common/include/minix/com.h @@ -260,6 +260,9 @@ #define STATVFS_LEN m1_i1 #define STATVFS_NAME m1_p1 #define STATVFS_BUF m1_p2 + +#define PM_GETSID_PID m1_i1 + /*===========================================================================* * Messages for networking layer * *===========================================================================*/ diff --git a/lib/nbsd_libc/sys-minix/Makefile.inc b/lib/nbsd_libc/sys-minix/Makefile.inc index ee855cc46..3442c9385 100644 --- a/lib/nbsd_libc/sys-minix/Makefile.inc +++ b/lib/nbsd_libc/sys-minix/Makefile.inc @@ -1,6 +1,6 @@ .PATH: ${.CURDIR}/sys-minix -SRCS+= accept.c access.c bind.c brk.c sbrk.c m_closefrom.c compat.S \ +SRCS+= accept.c access.c bind.c brk.c sbrk.c m_closefrom.c getsid.c compat.S \ chdir.c chmod.c fchmod.c chown.c fchown.c chroot.c close.c \ connect.c dup.c dup2.c execve.c fcntl.c flock.c fpathconf.c fork.c \ fstatfs.c fstatvfs.c fsync.c ftruncate.c getdents.c getegid.c getgid.c \ diff --git a/lib/nbsd_libc/sys-minix/getsid.c b/lib/nbsd_libc/sys-minix/getsid.c new file mode 100644 index 000000000..c4505fcc1 --- /dev/null +++ b/lib/nbsd_libc/sys-minix/getsid.c @@ -0,0 +1,14 @@ +#include +#include +#include "namespace.h" + +#include + +pid_t getsid(pid_t p) +{ + message m; + + memset(&m, 0, sizeof(m)); + m.PM_GETSID_PID = p; + return(_syscall(PM_PROC_NR, PM_GETSID, &m)); +} diff --git a/servers/pm/getset.c b/servers/pm/getset.c index f826c080d..daf5b797f 100644 --- a/servers/pm/getset.c +++ b/servers/pm/getset.c @@ -18,7 +18,7 @@ *===========================================================================*/ PUBLIC int do_get() { -/* Handle GETUID, GETGID, GETPID, GETPGRP. +/* Handle GETUID, GETGID, GETPID, GETPGRP, GETSID. */ register struct mproc *rmp = mp; @@ -68,6 +68,16 @@ PUBLIC int do_get() r = rmp->mp_procgrp; break; + case PM_GETSID: + { + struct mproc *target; + pid_t p = m_in.PM_GETSID_PID; + target = p ? find_proc(p) : &mproc[who_p]; + r = ESRCH; + if(target) + r = target->mp_procgrp; + break; + } default: r = EINVAL; break; diff --git a/servers/pm/table.c b/servers/pm/table.c index 444455dc2..6a69002ec 100644 --- a/servers/pm/table.c +++ b/servers/pm/table.c @@ -125,6 +125,7 @@ _PROTOTYPE (int (*call_vec[]), (void) ) = { do_getdma, /* 110 = getdma */ do_srv_kill, /* 111 = srv_kill */ no_sys, /* 112 = gcov_flush */ + do_get, /* 113 = getsid */ }; /* This should not fail with "array size is negative": */ extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1]; diff --git a/servers/vfs/table.c b/servers/vfs/table.c index 5385e7b14..0f05fd528 100644 --- a/servers/vfs/table.c +++ b/servers/vfs/table.c @@ -129,6 +129,7 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = { no_sys, /* 110 = (getdma) */ no_sys, /* 111 = (srv_kill) */ do_gcov_flush, /* 112 = gcov_flush */ + no_sys, /* 113 = (getsid) */ }; /* This should not fail with "array size is negative": */ extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1]; -- 2.44.0