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));
|
2014-05-19 11:18:20 +02:00
|
|
|
m.m_lc_pm_rusage.who = who;
|
|
|
|
m.m_lc_pm_rusage.addr = (vir_bytes)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));
|
2014-05-19 11:18:20 +02:00
|
|
|
m.m_lc_vfs_rusage.addr = (vir_bytes)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));
|
2014-05-19 11:18:20 +02:00
|
|
|
m.m_lc_vm_rusage.addr = (vir_bytes)r_usage;
|
2013-06-25 14:41:01 +02:00
|
|
|
return _syscall(VM_PROC_NR, VM_GETRUSAGE, &m);
|
|
|
|
}
|