New getrusage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux