2013-06-25 14:41:01 +02:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <lib.h>
|
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
#include <string.h>
|
2013-06-25 14:41:01 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
|
|
|
int getrusage(int who, struct rusage *r_usage)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
message m;
|
2013-11-04 22:48:08 +01:00
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
2013-06-25 14:41:01 +02:00
|
|
|
m.RU_WHO = who;
|
2013-11-04 22:48:08 +01:00
|
|
|
m.RU_RUSAGE_ADDR = (char *) r_usage;
|
2013-06-25 14:41:01 +02:00
|
|
|
|
|
|
|
if (r_usage == NULL) {
|
|
|
|
errno = EFAULT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) {
|
|
|
|
errno = EINVAL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(r_usage, 0, sizeof(struct rusage));
|
2013-10-28 22:30:41 +01:00
|
|
|
if ((rc = _syscall(PM_PROC_NR, PM_GETRUSAGE, &m)) < 0)
|
2013-06-25 14:41:01 +02:00
|
|
|
return rc;
|
2013-11-04 22:48:08 +01:00
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
|
|
m.RU_RUSAGE_ADDR = (char *) r_usage;
|
2013-10-28 22:30:41 +01:00
|
|
|
if ((rc = _syscall(VFS_PROC_NR, VFS_GETRUSAGE, &m)) < 0)
|
2013-06-25 14:41:01 +02:00
|
|
|
return rc;
|
2013-11-04 22:48:08 +01:00
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
|
|
m.RU_RUSAGE_ADDR = (char *) r_usage;
|
2013-06-25 14:41:01 +02:00
|
|
|
return _syscall(VM_PROC_NR, VM_GETRUSAGE, &m);
|
|
|
|
}
|