[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>
This commit is contained in:
Serge E. Hallyn 2006-10-02 02:18:14 -07:00 committed by Linus Torvalds
parent 96b644bdec
commit 4865ecf131
9 changed files with 121 additions and 12 deletions

View file

@ -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);
}