diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2010-03-07 21:43:27 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2011-05-10 17:35:35 -0400 |
commit | 34482e89a5218f0f9317abf1cfba3bb38b5c29dd (patch) | |
tree | 94a2c2409fbbef8a01aae589469ee44180e6e04f | |
parent | 13b6f57623bc485e116344fe91fbcb29f149242b (diff) |
ns proc: Add support for the uts namespace
Acked-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | fs/proc/namespaces.c | 3 | ||||
-rw-r--r-- | include/linux/proc_fs.h | 1 | ||||
-rw-r--r-- | kernel/utsname.c | 39 |
3 files changed, 43 insertions, 0 deletions
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index dcbd483e9915..b017181f1273 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c | |||
@@ -19,6 +19,9 @@ static const struct proc_ns_operations *ns_entries[] = { | |||
19 | #ifdef CONFIG_NET_NS | 19 | #ifdef CONFIG_NET_NS |
20 | &netns_operations, | 20 | &netns_operations, |
21 | #endif | 21 | #endif |
22 | #ifdef CONFIG_UTS_NS | ||
23 | &utsns_operations, | ||
24 | #endif | ||
22 | }; | 25 | }; |
23 | 26 | ||
24 | static const struct file_operations ns_file_operations = { | 27 | static const struct file_operations ns_file_operations = { |
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 62126ec6ede9..52aa89df8a6d 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -266,6 +266,7 @@ struct proc_ns_operations { | |||
266 | int (*install)(struct nsproxy *nsproxy, void *ns); | 266 | int (*install)(struct nsproxy *nsproxy, void *ns); |
267 | }; | 267 | }; |
268 | extern const struct proc_ns_operations netns_operations; | 268 | extern const struct proc_ns_operations netns_operations; |
269 | extern const struct proc_ns_operations utsns_operations; | ||
269 | 270 | ||
270 | union proc_op { | 271 | union proc_op { |
271 | int (*proc_get_link)(struct inode *, struct path *); | 272 | int (*proc_get_link)(struct inode *, struct path *); |
diff --git a/kernel/utsname.c b/kernel/utsname.c index 44646179eaba..bff131b9510a 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/user_namespace.h> | 17 | #include <linux/user_namespace.h> |
18 | #include <linux/proc_fs.h> | ||
18 | 19 | ||
19 | static struct uts_namespace *create_uts_ns(void) | 20 | static struct uts_namespace *create_uts_ns(void) |
20 | { | 21 | { |
@@ -79,3 +80,41 @@ void free_uts_ns(struct kref *kref) | |||
79 | put_user_ns(ns->user_ns); | 80 | put_user_ns(ns->user_ns); |
80 | kfree(ns); | 81 | kfree(ns); |
81 | } | 82 | } |
83 | |||
84 | static void *utsns_get(struct task_struct *task) | ||
85 | { | ||
86 | struct uts_namespace *ns = NULL; | ||
87 | struct nsproxy *nsproxy; | ||
88 | |||
89 | rcu_read_lock(); | ||
90 | nsproxy = task_nsproxy(task); | ||
91 | if (nsproxy) { | ||
92 | ns = nsproxy->uts_ns; | ||
93 | get_uts_ns(ns); | ||
94 | } | ||
95 | rcu_read_unlock(); | ||
96 | |||
97 | return ns; | ||
98 | } | ||
99 | |||
100 | static void utsns_put(void *ns) | ||
101 | { | ||
102 | put_uts_ns(ns); | ||
103 | } | ||
104 | |||
105 | static int utsns_install(struct nsproxy *nsproxy, void *ns) | ||
106 | { | ||
107 | get_uts_ns(ns); | ||
108 | put_uts_ns(nsproxy->uts_ns); | ||
109 | nsproxy->uts_ns = ns; | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | const struct proc_ns_operations utsns_operations = { | ||
114 | .name = "uts", | ||
115 | .type = CLONE_NEWUTS, | ||
116 | .get = utsns_get, | ||
117 | .put = utsns_put, | ||
118 | .install = utsns_install, | ||
119 | }; | ||
120 | |||