Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030452AbWHOSYp (ORCPT ); Tue, 15 Aug 2006 14:24:45 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030444AbWHOSYQ (ORCPT ); Tue, 15 Aug 2006 14:24:16 -0400 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:17630 "EHLO ebiederm.dsl.xmission.com") by vger.kernel.org with ESMTP id S1030447AbWHOSYK (ORCPT ); Tue, 15 Aug 2006 14:24:10 -0400 From: "Eric W. Biederman" To: Andrew Morton Cc: , , Oleg Nesterov , "Eric W. Biederman" Subject: [PATCH 1/7] pid: Implement access helpers for a tacks various process groups. Date: Tue, 15 Aug 2006 12:23:06 -0600 Message-Id: <11556661922952-git-send-email-ebiederm@xmission.com> X-Mailer: git-send-email 1.4.2.g3cd4f In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1629 Lines: 53 task_session returns the struct pid of a tasks session. task_pgrp returns the struct pid of a tasks process group. task_tgid returns the struct pid of a tasks thread group. task_pid returns the struct pid of a tasks process id. These can be used to avoid unnecessary hash table lookups, and to implement safe pid comparisions in the face of a pid namespace. Signed-off-by: Eric W. Biederman --- include/linux/sched.h | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 03d96b9..6560dd3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1042,6 +1042,26 @@ static inline pid_t process_group(struct return tsk->signal->pgrp; } +static inline struct pid *task_pid(struct task_struct *task) +{ + return task->pids[PIDTYPE_PID].pid; +} + +static inline struct pid *task_tgid(struct task_struct *task) +{ + return task->group_leader->pids[PIDTYPE_PID].pid; +} + +static inline struct pid *task_pgrp(struct task_struct *task) +{ + return task->group_leader->pids[PIDTYPE_PGID].pid; +} + +static inline struct pid *task_session(struct task_struct *task) +{ + return task->group_leader->pids[PIDTYPE_SID].pid; +} + /** * pid_alive - check that a task structure is not stale * @p: Task structure to be checked. -- 1.4.2.rc3.g7e18e-dirty - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/