Re: [PATCH] proc: Add complete process group list

From: Oleg Nesterov
Date: Tue Jun 22 2010 - 12:06:43 EST


On 06/23, Mike McCormack wrote:
>
> The new file /proc/<pid>/groups consists of a single group id per line,
> with each line being 11 characters long. This should be enough space
> for 16bit or 32bit group ids.
>
> This feature might be useful for a server listening on a unix domain pipe
> to determine the list of groups that a client process is in from its pid.

As usual, I can never comment whether we need this or not. Just a minor
nit about the code,

> +static int groups_proc_show(struct seq_file *m, void *v)
> +{
> + struct inode *inode = m->private;
> + struct group_info *group_info;
> + struct task_struct *task;
> + const struct cred *cred;
> + struct pid *pid;
> + unsigned int g;
> +
> + pid = proc_pid(inode);
> + task = get_pid_task(pid, PIDTYPE_PID);

get_proc_task() ?

> + if (!task)
> + return -ESRCH;
> +
> + cred = get_task_cred(task);

OTOH. Not that I think this is terribly important, but I don't think
this needs get_task_struct + get_cred,

group_info = NULL;

rcu_read_lock();
task = pid_task(proc_pid(inode), PIDTYPE_PID);
if (task) {
group_info = _task_cred(task)->group_info;
get_group_info(group_info);
}
rcu_read_unlock();

if (!group_info)
retrn ESRCH;

Feel free to ignore though.

Oleg.

--
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/