diff options
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 1b3586fe753a..b2e5f78fd281 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -403,6 +403,8 @@ struct pid *get_task_pid(struct task_struct *task, enum pid_type type) | |||
403 | { | 403 | { |
404 | struct pid *pid; | 404 | struct pid *pid; |
405 | rcu_read_lock(); | 405 | rcu_read_lock(); |
406 | if (type != PIDTYPE_PID) | ||
407 | task = task->group_leader; | ||
406 | pid = get_pid(task->pids[type].pid); | 408 | pid = get_pid(task->pids[type].pid); |
407 | rcu_read_unlock(); | 409 | rcu_read_unlock(); |
408 | return pid; | 410 | return pid; |
@@ -450,11 +452,24 @@ pid_t pid_vnr(struct pid *pid) | |||
450 | } | 452 | } |
451 | EXPORT_SYMBOL_GPL(pid_vnr); | 453 | EXPORT_SYMBOL_GPL(pid_vnr); |
452 | 454 | ||
453 | pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | 455 | pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type, |
456 | struct pid_namespace *ns) | ||
454 | { | 457 | { |
455 | return pid_nr_ns(task_pid(tsk), ns); | 458 | pid_t nr = 0; |
459 | |||
460 | rcu_read_lock(); | ||
461 | if (!ns) | ||
462 | ns = current->nsproxy->pid_ns; | ||
463 | if (likely(pid_alive(task))) { | ||
464 | if (type != PIDTYPE_PID) | ||
465 | task = task->group_leader; | ||
466 | nr = pid_nr_ns(task->pids[type].pid, ns); | ||
467 | } | ||
468 | rcu_read_unlock(); | ||
469 | |||
470 | return nr; | ||
456 | } | 471 | } |
457 | EXPORT_SYMBOL(task_pid_nr_ns); | 472 | EXPORT_SYMBOL(__task_pid_nr_ns); |
458 | 473 | ||
459 | pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | 474 | pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) |
460 | { | 475 | { |
@@ -462,18 +477,6 @@ pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | |||
462 | } | 477 | } |
463 | EXPORT_SYMBOL(task_tgid_nr_ns); | 478 | EXPORT_SYMBOL(task_tgid_nr_ns); |
464 | 479 | ||
465 | pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | ||
466 | { | ||
467 | return pid_nr_ns(task_pgrp(tsk), ns); | ||
468 | } | ||
469 | EXPORT_SYMBOL(task_pgrp_nr_ns); | ||
470 | |||
471 | pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns) | ||
472 | { | ||
473 | return pid_nr_ns(task_session(tsk), ns); | ||
474 | } | ||
475 | EXPORT_SYMBOL(task_session_nr_ns); | ||
476 | |||
477 | struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) | 480 | struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) |
478 | { | 481 | { |
479 | return ns_of_pid(task_pid(tsk)); | 482 | return ns_of_pid(task_pid(tsk)); |