]> Zhao Yanbai Git Server - minix.git/commitdiff
Add getnucred system call. Contributed by Thomas Cort
authorThomas Veerman <thomas@minix3.org>
Thu, 15 Jul 2010 13:24:57 +0000 (13:24 +0000)
committerThomas Veerman <thomas@minix3.org>
Thu, 15 Jul 2010 13:24:57 +0000 (13:24 +0000)
include/minix/com.h
lib/libc/other/Makefile.inc
lib/libc/other/_getnucred.c [new file with mode: 0644]
lib/libc/syscall/Makefile.inc
lib/libc/syscall/getnucred.S [new file with mode: 0644]

index 8596ba853ff801ef77d36181ef38e9102d3d7a1e..16526b20d066850462575feed11a5d863fc04926 100644 (file)
 #define PM_ENDPT                               m1_i1
 #define PM_PENDPT                              m1_i2
 
+#define PM_NUID                                        m2_i1
+#define PM_NGID                                        m2_i2
+
 /* Field names for GETSYSINFO_UP (PM). */
 #define SIU_WHAT       m2_i1
 #define SIU_LEN                m2_i2
index 14a63ab78dcce3e6d2c9820235a9c8c734298291..ffe2a0bef46c5da75989ddd7c353bdb21ca4a696 100644 (file)
@@ -13,6 +13,7 @@ SRCS+=  \
        _getdents.c \
        _getdma.c \
        _getnpid.c \
+       _getnucred.c \
        _getnuid.c \
        _getngid.c \
        _getnprocnr.c \
diff --git a/lib/libc/other/_getnucred.c b/lib/libc/other/_getnucred.c
new file mode 100644 (file)
index 0000000..4c71aa7
--- /dev/null
@@ -0,0 +1,29 @@
+#include <lib.h>
+#define getnucred      _getnucred
+#include <errno.h>
+#include <sys/ucred.h>
+#include <unistd.h>
+
+PUBLIC int getnucred(endpoint_t proc_ep, struct ucred *ucred)
+{
+  message m;
+  pid_t pid;
+
+  if (ucred == NULL) {
+    errno = EFAULT;
+    return -1;
+  }
+
+  m.m1_i1 = proc_ep;           /* search for this process */
+
+  pid = _syscall(PM_PROC_NR, GETEPINFO, &m);
+  if (pid < 0) {
+     return -1;
+  }
+
+  ucred->pid = pid;
+  ucred->uid = m.PM_NUID;
+  ucred->gid = m.PM_NGID;
+
+  return 0;
+}
index f0d177fb0f6be274c8a04aa113681f38c499fb36..05ed54ebf072fb6b5b7eb729c9f6a801266fc01d 100644 (file)
@@ -46,6 +46,7 @@ SRCS+=  \
        getgroups.S \
        getitimer.S \
        getnpid.S \
+       getnucred.S \
        getnuid.S \
        getngid.S \
        getnprocnr.S \
diff --git a/lib/libc/syscall/getnucred.S b/lib/libc/syscall/getnucred.S
new file mode 100644 (file)
index 0000000..4e436e6
--- /dev/null
@@ -0,0 +1,7 @@
+.text
+.extern        __getnucred
+.globl _getnucred
+.balign        2
+
+_getnucred:
+       jmp     __getnucred