summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2006-10-02 02:18:14 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 07:57:21 -0700
commit4865ecf1315b450ab3317a745a6678c04d311e40 (patch)
tree6cf5d3028f8642eba2a8094eb413db080cc9219c /kernel
parent96b644bdec977b97a45133e5b4466ba47a7a5e65 (diff)
downloadblackbird-op-linux-4865ecf1315b450ab3317a745a6678c04d311e40.tar.gz
blackbird-op-linux-4865ecf1315b450ab3317a745a6678c04d311e40.zip
[PATCH] namespaces: utsname: implement utsname namespaces
This patch defines the uts namespace and some manipulators. Adds the uts namespace to task_struct, and initializes a system-wide init namespace. It leaves a #define for system_utsname so sysctl will compile. This define will be removed in a separate patch. [akpm@osdl.org: build fix, cleanup] 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')
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/nsproxy.c14
-rw-r--r--kernel/utsname.c42
3 files changed, 57 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 6ec53009b866..d948ca12acf0 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
obj-$(CONFIG_SECCOMP) += seccomp.o
obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
obj-$(CONFIG_RELAY) += relay.o
+obj-$(CONFIG_UTS_NS) += utsname.o
obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index e10385c17f73..47c19280c55b 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -14,6 +14,7 @@
#include <linux/nsproxy.h>
#include <linux/init_task.h>
#include <linux/namespace.h>
+#include <linux/utsname.h>
struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
@@ -59,6 +60,8 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig)
if (ns) {
if (ns->namespace)
get_namespace(ns->namespace);
+ if (ns->uts_ns)
+ get_uts_ns(ns->uts_ns);
}
return ns;
@@ -97,6 +100,15 @@ int copy_namespaces(int flags, struct task_struct *tsk)
goto out;
}
+ err = copy_utsname(flags, tsk);
+ if (err) {
+ if (new_ns->namespace)
+ put_namespace(new_ns->namespace);
+ tsk->nsproxy = old_ns;
+ put_nsproxy(new_ns);
+ goto out;
+ }
+
out:
put_nsproxy(old_ns);
return err;
@@ -106,5 +118,7 @@ void free_nsproxy(struct nsproxy *ns)
{
if (ns->namespace)
put_namespace(ns->namespace);
+ if (ns->uts_ns)
+ put_uts_ns(ns->uts_ns);
kfree(ns);
}
diff --git a/kernel/utsname.c b/kernel/utsname.c
new file mode 100644
index 000000000000..1824384ecfa3
--- /dev/null
+++ b/kernel/utsname.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2004 IBM Corporation
+ *
+ * Author: Serge Hallyn <serue@us.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ */
+
+#include <linux/module.h>
+#include <linux/uts.h>
+#include <linux/utsname.h>
+#include <linux/version.h>
+
+/*
+ * Copy task tsk's utsname namespace, or clone it if flags
+ * specifies CLONE_NEWUTS. In latter case, changes to the
+ * utsname of this process won't be seen by parent, and vice
+ * versa.
+ */
+int copy_utsname(int flags, struct task_struct *tsk)
+{
+ struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
+ int err = 0;
+
+ if (!old_ns)
+ return 0;
+
+ get_uts_ns(old_ns);
+
+ return err;
+}
+
+void free_uts_ns(struct kref *kref)
+{
+ struct uts_namespace *ns;
+
+ ns = container_of(kref, struct uts_namespace, kref);
+ kfree(ns);
+}
OpenPOWER on IntegriCloud