diff options
author | Serge E. Hallyn <serue@us.ibm.com> | 2006-10-02 05:18:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 10:57:21 -0400 |
commit | 4865ecf1315b450ab3317a745a6678c04d311e40 (patch) | |
tree | 6cf5d3028f8642eba2a8094eb413db080cc9219c /include/linux/utsname.h | |
parent | 96b644bdec977b97a45133e5b4466ba47a7a5e65 (diff) |
[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 'include/linux/utsname.h')
-rw-r--r-- | include/linux/utsname.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 77e97a5755d9..afa54e1542b3 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h | |||
@@ -1,6 +1,11 @@ | |||
1 | #ifndef _LINUX_UTSNAME_H | 1 | #ifndef _LINUX_UTSNAME_H |
2 | #define _LINUX_UTSNAME_H | 2 | #define _LINUX_UTSNAME_H |
3 | 3 | ||
4 | #include <linux/sched.h> | ||
5 | #include <linux/kref.h> | ||
6 | #include <linux/nsproxy.h> | ||
7 | #include <asm/atomic.h> | ||
8 | |||
4 | #define __OLD_UTS_LEN 8 | 9 | #define __OLD_UTS_LEN 8 |
5 | 10 | ||
6 | struct oldold_utsname { | 11 | struct oldold_utsname { |
@@ -30,17 +35,46 @@ struct new_utsname { | |||
30 | char domainname[65]; | 35 | char domainname[65]; |
31 | }; | 36 | }; |
32 | 37 | ||
33 | extern struct new_utsname system_utsname; | 38 | struct uts_namespace { |
39 | struct kref kref; | ||
40 | struct new_utsname name; | ||
41 | }; | ||
42 | extern struct uts_namespace init_uts_ns; | ||
43 | |||
44 | static inline void get_uts_ns(struct uts_namespace *ns) | ||
45 | { | ||
46 | kref_get(&ns->kref); | ||
47 | } | ||
48 | |||
49 | #ifdef CONFIG_UTS_NS | ||
50 | extern int copy_utsname(int flags, struct task_struct *tsk); | ||
51 | extern void free_uts_ns(struct kref *kref); | ||
52 | |||
53 | static inline void put_uts_ns(struct uts_namespace *ns) | ||
54 | { | ||
55 | kref_put(&ns->kref, free_uts_ns); | ||
56 | } | ||
57 | #else | ||
58 | static inline int copy_utsname(int flags, struct task_struct *tsk) | ||
59 | { | ||
60 | return 0; | ||
61 | } | ||
62 | static inline void put_uts_ns(struct uts_namespace *ns) | ||
63 | { | ||
64 | } | ||
65 | #endif | ||
34 | 66 | ||
35 | static inline struct new_utsname *utsname(void) | 67 | static inline struct new_utsname *utsname(void) |
36 | { | 68 | { |
37 | return &system_utsname; | 69 | return ¤t->nsproxy->uts_ns->name; |
38 | } | 70 | } |
39 | 71 | ||
40 | static inline struct new_utsname *init_utsname(void) | 72 | static inline struct new_utsname *init_utsname(void) |
41 | { | 73 | { |
42 | return &system_utsname; | 74 | return &init_uts_ns.name; |
43 | } | 75 | } |
44 | 76 | ||
77 | #define system_utsname init_uts_ns.name | ||
78 | |||
45 | extern struct rw_semaphore uts_sem; | 79 | extern struct rw_semaphore uts_sem; |
46 | #endif | 80 | #endif |