diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-19 02:40:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:40 -0400 |
commit | b488893a390edfe027bae7a46e9af8083e740668 (patch) | |
tree | c469a7f99ad01005a73011c029eb5e5d15454559 /drivers/char | |
parent | 3eb07c8c8adb6f0572baba844ba2d9e501654316 (diff) |
pid namespaces: changes to show virtual ids to user
This is the largest patch in the set. Make all (I hope) the places where
the pid is shown to or get from user operate on the virtual pids.
The idea is:
- all in-kernel data structures must store either struct pid itself
or the pid's global nr, obtained with pid_nr() call;
- when seeking the task from kernel code with the stored id one
should use find_task_by_pid() call that works with global pids;
- when showing pid's numerical value to the user the virtual one
should be used, but however when one shows task's pid outside this
task's namespace the global one is to be used;
- when getting the pid from userspace one need to consider this as
the virtual one and use appropriate task/pid-searching functions.
[akpm@linux-foundation.org: build fix]
[akpm@linux-foundation.org: nuther build fix]
[akpm@linux-foundation.org: yet nuther build fix]
[akpm@linux-foundation.org: remove unneeded casts]
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Paul Menage <menage@google.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tty_io.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 9820f86831ee..e40544947135 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -103,6 +103,7 @@ | |||
103 | #include <linux/selection.h> | 103 | #include <linux/selection.h> |
104 | 104 | ||
105 | #include <linux/kmod.h> | 105 | #include <linux/kmod.h> |
106 | #include <linux/nsproxy.h> | ||
106 | 107 | ||
107 | #undef TTY_DEBUG_HANGUP | 108 | #undef TTY_DEBUG_HANGUP |
108 | 109 | ||
@@ -3107,7 +3108,7 @@ static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t | |||
3107 | */ | 3108 | */ |
3108 | if (tty == real_tty && current->signal->tty != real_tty) | 3109 | if (tty == real_tty && current->signal->tty != real_tty) |
3109 | return -ENOTTY; | 3110 | return -ENOTTY; |
3110 | return put_user(pid_nr(real_tty->pgrp), p); | 3111 | return put_user(pid_vnr(real_tty->pgrp), p); |
3111 | } | 3112 | } |
3112 | 3113 | ||
3113 | /** | 3114 | /** |
@@ -3141,7 +3142,7 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t | |||
3141 | if (pgrp_nr < 0) | 3142 | if (pgrp_nr < 0) |
3142 | return -EINVAL; | 3143 | return -EINVAL; |
3143 | rcu_read_lock(); | 3144 | rcu_read_lock(); |
3144 | pgrp = find_pid(pgrp_nr); | 3145 | pgrp = find_vpid(pgrp_nr); |
3145 | retval = -ESRCH; | 3146 | retval = -ESRCH; |
3146 | if (!pgrp) | 3147 | if (!pgrp) |
3147 | goto out_unlock; | 3148 | goto out_unlock; |
@@ -3178,7 +3179,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _ | |||
3178 | return -ENOTTY; | 3179 | return -ENOTTY; |
3179 | if (!real_tty->session) | 3180 | if (!real_tty->session) |
3180 | return -ENOTTY; | 3181 | return -ENOTTY; |
3181 | return put_user(pid_nr(real_tty->session), p); | 3182 | return put_user(pid_vnr(real_tty->session), p); |
3182 | } | 3183 | } |
3183 | 3184 | ||
3184 | /** | 3185 | /** |