diff options
author | Serge E. Hallyn <serue@us.ibm.com> | 2006-10-02 05:18:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 10:57:20 -0400 |
commit | 1651e14e28a2d9f446018ef522882e0709a2ce4f (patch) | |
tree | 401ff78624fdc4b445f3f95174a223acaf6a4ca0 /kernel/nsproxy.c | |
parent | 0437eb594e6e5e699248f865482e61034be846d0 (diff) |
[PATCH] namespaces: incorporate fs namespace into nsproxy
This moves the mount namespace into the nsproxy. The mount namespace count
now refers to the number of nsproxies point to it, rather than the number of
tasks. As a result, the unshare_namespace() function in kernel/fork.c no
longer checks whether it is being shared.
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Cc: Kirill Korotaev <dev@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Andrey Savochkin <saw@sw.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/nsproxy.c')
-rw-r--r-- | kernel/nsproxy.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index a3612f82f187..e10385c17f73 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/version.h> | 13 | #include <linux/version.h> |
14 | #include <linux/nsproxy.h> | 14 | #include <linux/nsproxy.h> |
15 | #include <linux/init_task.h> | 15 | #include <linux/init_task.h> |
16 | #include <linux/namespace.h> | ||
16 | 17 | ||
17 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); | 18 | struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); |
18 | 19 | ||
@@ -55,6 +56,11 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig) | |||
55 | { | 56 | { |
56 | struct nsproxy *ns = clone_namespaces(orig); | 57 | struct nsproxy *ns = clone_namespaces(orig); |
57 | 58 | ||
59 | if (ns) { | ||
60 | if (ns->namespace) | ||
61 | get_namespace(ns->namespace); | ||
62 | } | ||
63 | |||
58 | return ns; | 64 | return ns; |
59 | } | 65 | } |
60 | 66 | ||
@@ -65,16 +71,40 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig) | |||
65 | int copy_namespaces(int flags, struct task_struct *tsk) | 71 | int copy_namespaces(int flags, struct task_struct *tsk) |
66 | { | 72 | { |
67 | struct nsproxy *old_ns = tsk->nsproxy; | 73 | struct nsproxy *old_ns = tsk->nsproxy; |
74 | struct nsproxy *new_ns; | ||
75 | int err = 0; | ||
68 | 76 | ||
69 | if (!old_ns) | 77 | if (!old_ns) |
70 | return 0; | 78 | return 0; |
71 | 79 | ||
72 | get_nsproxy(old_ns); | 80 | get_nsproxy(old_ns); |
73 | 81 | ||
74 | return 0; | 82 | if (!(flags & CLONE_NEWNS)) |
83 | return 0; | ||
84 | |||
85 | new_ns = clone_namespaces(old_ns); | ||
86 | if (!new_ns) { | ||
87 | err = -ENOMEM; | ||
88 | goto out; | ||
89 | } | ||
90 | |||
91 | tsk->nsproxy = new_ns; | ||
92 | |||
93 | err = copy_namespace(flags, tsk); | ||
94 | if (err) { | ||
95 | tsk->nsproxy = old_ns; | ||
96 | put_nsproxy(new_ns); | ||
97 | goto out; | ||
98 | } | ||
99 | |||
100 | out: | ||
101 | put_nsproxy(old_ns); | ||
102 | return err; | ||
75 | } | 103 | } |
76 | 104 | ||
77 | void free_nsproxy(struct nsproxy *ns) | 105 | void free_nsproxy(struct nsproxy *ns) |
78 | { | 106 | { |
107 | if (ns->namespace) | ||
108 | put_namespace(ns->namespace); | ||
79 | kfree(ns); | 109 | kfree(ns); |
80 | } | 110 | } |