Implement getrusage
Implement getrusage. These fields of struct rusage are not supported and always set to zero at this time long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary context switches */ test75.c is the unit test for this new function Change-Id: I3f1eb69de1fce90d087d76773b09021fc6106539
This commit is contained in:
committed by
Gerrit Code Review
parent
4241cc5d98
commit
64f10ee644
@@ -18,7 +18,8 @@ SRCS+= accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \
|
||||
sigprocmask.c socket.c socketpair.c stat.c statvfs.c symlink.c \
|
||||
sync.c syscall.c sysuname.c truncate.c umask.c unlink.c write.c \
|
||||
utimensat.c utimes.c futimes.c lutimes.c futimens.c \
|
||||
_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c
|
||||
_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \
|
||||
getrusage.c
|
||||
|
||||
# Minix specific syscalls.
|
||||
SRCS+= cprofile.c lseek64.c sprofile.c _mcontext.c
|
||||
|
||||
32
lib/libc/sys-minix/getrusage.c
Normal file
32
lib/libc/sys-minix/getrusage.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include "namespace.h"
|
||||
#include <lib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int getrusage(int who, struct rusage *r_usage)
|
||||
{
|
||||
int rc;
|
||||
message m;
|
||||
m.RU_WHO = who;
|
||||
m.RU_RUSAGE_ADDR = r_usage;
|
||||
|
||||
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));
|
||||
if ((rc = _syscall(PM_PROC_NR, GETRUSAGE, &m)) < 0)
|
||||
return rc;
|
||||
m.RU_RUSAGE_ADDR = r_usage;
|
||||
if ((rc = _syscall(VFS_PROC_NR, GETRUSAGE, &m)) < 0)
|
||||
return rc;
|
||||
m.RU_RUSAGE_ADDR = r_usage;
|
||||
return _syscall(VM_PROC_NR, VM_GETRUSAGE, &m);
|
||||
}
|
||||
@@ -228,7 +228,7 @@ MAN+= accept.2 access.2 acct.2 bind.2 brk.2 chdir.2 \
|
||||
flock.2 fork.2 fsync.2 getcontext.2 getdents.2 \
|
||||
getfh.2 getvfsstat.2 getgid.2 getgroups.2 \
|
||||
getitimer.2 getlogin.2 getpeername.2 getpgrp.2 getpid.2 \
|
||||
getpriority.2 getrlimit.2 getrusage.2 getsid.2 getsockname.2 \
|
||||
getpriority.2 getrlimit.2 getsid.2 getsockname.2 \
|
||||
getsockopt.2 gettimeofday.2 getuid.2 intro.2 ioctl.2 issetugid.2 \
|
||||
kill.2 kqueue.2 ktrace.2 \
|
||||
lfs_bmapv.2 lfs_markv.2 lfs_segclean.2 lfs_segwait.2 \
|
||||
@@ -244,7 +244,7 @@ MAN+= accept.2 access.2 acct.2 bind.2 brk.2 chdir.2 \
|
||||
mprotect.2 mremap.2 msgctl.2 msgget.2 msgrcv.2 msgsnd.2 msync.2 \
|
||||
munmap.2 nanosleep.2 nfssvc.2 ntp_adjtime.2 open.2 pathconf.2 pipe.2
|
||||
.else
|
||||
MAN+= adjtime.2 clock_settime.2 pipe.2
|
||||
MAN+= adjtime.2 clock_settime.2 pipe.2 getrusage.2
|
||||
.endif # !defined(__MINIX)
|
||||
.if !defined(__MINIX)
|
||||
MAN+= pmc_control.2 poll.2 posix_fadvise.2 profil.2 ptrace.2 __quotactl.2 \
|
||||
|
||||
@@ -228,6 +228,11 @@ int libexec_load_elf(struct exec_info *execi)
|
||||
if(first || startv > vaddr) startv = vaddr;
|
||||
first = 0;
|
||||
|
||||
if ((ph->p_flags & PF_X) != 0 && execi->text_size < seg_membytes)
|
||||
execi->text_size = seg_membytes;
|
||||
else
|
||||
execi->data_size = seg_membytes;
|
||||
|
||||
if(try_mmap && execi->memmap(execi, vaddr, fbytes, foffset, clearend, mmap_prot) == OK) {
|
||||
#if ELF_DEBUG
|
||||
printf("libexec: mmap 0x%lx-0x%lx done, clearend 0x%x\n",
|
||||
|
||||
@@ -32,6 +32,8 @@ struct exec_info {
|
||||
int allow_setuid; /* Allow set{u,g}id execution? */
|
||||
vir_bytes stack_size; /* Desired stack size */
|
||||
vir_bytes load_offset; /* Desired load offset */
|
||||
vir_bytes text_size; /* Text segment size */
|
||||
vir_bytes data_size; /* Data segment size */
|
||||
off_t filesize; /* How big is the file */
|
||||
|
||||
/* Callback pointers for use by libexec */
|
||||
|
||||
Reference in New Issue
Block a user