getrusage()

I just wrote one system call getrusage() today. paste it up.

int kgetrusage(int who, struct rusage *r_usage)
{
	int ret = 0;
	kprocess_t *proc = current->host;

	if (!proc)
		return -ENOSYS;

	if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
		return -EINVAL;

	if (!r_usage)
		return -EINVAL;

	switch (who) {
	case RUSAGE_SELF:
		memcpy((char *)r_usage, (char *)&proc->rs, sizeof(struct rusage));
		break;
	case RUSAGE_CHILDREN:
		if (!proc-->p_child)
			break;
		if (!proc->p_child->p_w4q)
			break;
		/*
		 * we should sum all children 's usages up?
		 */

		memcpy((char *)r_usage, (char *)&proc-->p_child->rs, sizeof(struct rusage));
		break;
	default:
		BUG();
	}
	return ret;
}

TO-DO list:
/Kernel/syscall.c:1023: error: ‘sys_setitimer’ undeclared here (not in a function)
../Kernel/syscall.c:1024: error: ‘sys_getitimer’ undeclared here (not in a function)
../Kernel/syscall.c:1025: error: ‘sys_vfork’ undeclared here (not in a function)
../Kernel/syscall.c:1026: error: ‘sys_select’ undeclared here (not in a function)
../Kernel/syscall.c:1027: error: ‘sys_getlogin’ undeclared here (not in a function)
../Kernel/syscall.c:1028: error: ‘sys_socketpair’ undeclared here (not in a function)
../Kernel/syscall.c:1029: error: ‘sys_seteuid’ undeclared here (not in a function)
../Kernel/syscall.c:1030: error: ‘sys_setegid’ undeclared here (not in a function)
../Kernel/syscall.c:1031: error: ‘sys_getdirentries’ undeclared here (not in a function)
../Kernel/syscall.c:1032: error: ‘sys_fstatfs’ undeclared here (not in a function)
../Kernel/syscall.c:1033: error: ‘sys_statfs’ undeclared here (not in a function)
../Kernel/syscall.c:1034: error: ‘sys_mmap’ undeclared here (not in a function)
../Kernel/syscall.c:1035: error: ‘sys_munmap’ undeclared here (not in a function)
../Kernel/syscall.c:1036: error: ‘sys_utimes’ undeclared here (not in a function)
../Kernel/syscall.c:1037: error: ‘sys_wait4’ undeclared here (not in a function)
../Kernel/syscall.c:1038: error: ‘sys_getrlimit’ undeclared here (not in a function)
../Kernel/syscall.c:1039: error: ‘sys_setrlimit’ undeclared here (not in a function)
../Kernel/syscall.c:1040: error: ‘sys_ftruncate’ undeclared here (not in a function)
../Kernel/syscall.c:1041: error: ‘sys_fsync’ undeclared here (not in a function)
../Kernel/syscall.c:1042: error: ‘sys_settimeofday’ undeclared here (not in a function)

Leave a Reply

Your email address will not be published. Required fields are marked *