Add getnucred system call. Contributed by Thomas Cort

This commit is contained in:
Thomas Veerman 2010-07-15 13:24:57 +00:00
parent 17a0731f28
commit ecc8a52f82
5 changed files with 41 additions and 0 deletions

View file

@ -876,6 +876,9 @@
#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

View file

@ -13,6 +13,7 @@ SRCS+= \
_getdents.c \
_getdma.c \
_getnpid.c \
_getnucred.c \
_getnuid.c \
_getngid.c \
_getnprocnr.c \

View file

@ -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;
}

View file

@ -46,6 +46,7 @@ SRCS+= \
getgroups.S \
getitimer.S \
getnpid.S \
getnucred.S \
getnuid.S \
getngid.S \
getnprocnr.S \

View file

@ -0,0 +1,7 @@
.text
.extern __getnucred
.globl _getnucred
.balign 2
_getnucred:
jmp __getnucred