New getrusage

From: Claudio Scordino
Date: Tue Nov 15 2005 - 11:59:58 EST


Actually, I think that a better implementation of getrusage would be the
following one, but it requires a (new) third parameter. That's why I didn't
suggest it...

Many thanks,

Claudio

Signed-off-by: Claudio Scordino <cloud.of.andor@xxxxxxxxx>

asmlinkage long sys_getrusage(int who, struct rusage __user *ru, pid_t pid)
{
struct rusage r;
struct task_struct* tsk = current;
if ((pid < 0) ||
((who != RUSAGE_SELF) && (who != RUSAGE_CHILDREN)))
return -EINVAL;
read_lock(&tasklist_lock);
if (pid > 0) {
tsk = find_task_by_pid(pid);
if (tsk == NULL)
goto bad;
if (((current->uid != tsk->euid) ||
(current->uid != tsk->suid) ||
(current->uid != tsk->uid) ||
(current->gid != tsk->egid) ||
(current->gid != tsk->sgid) ||
(current->gid != tsk->gid)) && !capable(CAP_SYS_PTRACE))
goto bad;
}
k_getrusage(tsk, who, &r);
read_unlock(&tasklist_lock);
return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;

bad:
read_unlock(&tasklist_lock);
return tsk ? -EPERM : -EINVAL;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/