aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/nsproxy.h2
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/utsname.h40
4 files changed, 42 insertions, 3 deletions
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 4865348ca8bd..e08531ec32f0 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -4,6 +4,7 @@
4#include <linux/file.h> 4#include <linux/file.h>
5#include <linux/rcupdate.h> 5#include <linux/rcupdate.h>
6#include <linux/irqflags.h> 6#include <linux/irqflags.h>
7#include <linux/utsname.h>
7#include <linux/lockdep.h> 8#include <linux/lockdep.h>
8 9
9#define INIT_FDTABLE \ 10#define INIT_FDTABLE \
@@ -72,6 +73,7 @@ extern struct nsproxy init_nsproxy;
72#define INIT_NSPROXY(nsproxy) { \ 73#define INIT_NSPROXY(nsproxy) { \
73 .count = ATOMIC_INIT(1), \ 74 .count = ATOMIC_INIT(1), \
74 .nslock = SPIN_LOCK_UNLOCKED, \ 75 .nslock = SPIN_LOCK_UNLOCKED, \
76 .uts_ns = &init_uts_ns, \
75 .namespace = NULL, \ 77 .namespace = NULL, \
76} 78}
77 79
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index 7ebe66670c59..9c2e0ad508db 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -5,6 +5,7 @@
5#include <linux/sched.h> 5#include <linux/sched.h>
6 6
7struct namespace; 7struct namespace;
8struct uts_namespace;
8 9
9/* 10/*
10 * A structure to contain pointers to all per-process 11 * A structure to contain pointers to all per-process
@@ -21,6 +22,7 @@ struct namespace;
21struct nsproxy { 22struct nsproxy {
22 atomic_t count; 23 atomic_t count;
23 spinlock_t nslock; 24 spinlock_t nslock;
25 struct uts_namespace *uts_ns;
24 struct namespace *namespace; 26 struct namespace *namespace;
25}; 27};
26extern struct nsproxy init_nsproxy; 28extern struct nsproxy init_nsproxy;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 670b89a20070..46d6f5be72f2 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -753,6 +753,7 @@ static inline void prefetch_stack(struct task_struct *t) { }
753struct audit_context; /* See audit.c */ 753struct audit_context; /* See audit.c */
754struct mempolicy; 754struct mempolicy;
755struct pipe_inode_info; 755struct pipe_inode_info;
756struct uts_namespace;
756 757
757enum sleep_type { 758enum sleep_type {
758 SLEEP_NORMAL, 759 SLEEP_NORMAL,
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
6struct oldold_utsname { 11struct oldold_utsname {
@@ -30,17 +35,46 @@ struct new_utsname {
30 char domainname[65]; 35 char domainname[65];
31}; 36};
32 37
33extern struct new_utsname system_utsname; 38struct uts_namespace {
39 struct kref kref;
40 struct new_utsname name;
41};
42extern struct uts_namespace init_uts_ns;
43
44static inline void get_uts_ns(struct uts_namespace *ns)
45{
46 kref_get(&ns->kref);
47}
48
49#ifdef CONFIG_UTS_NS
50extern int copy_utsname(int flags, struct task_struct *tsk);
51extern void free_uts_ns(struct kref *kref);
52
53static inline void put_uts_ns(struct uts_namespace *ns)
54{
55 kref_put(&ns->kref, free_uts_ns);
56}
57#else
58static inline int copy_utsname(int flags, struct task_struct *tsk)
59{
60 return 0;
61}
62static inline void put_uts_ns(struct uts_namespace *ns)
63{
64}
65#endif
34 66
35static inline struct new_utsname *utsname(void) 67static inline struct new_utsname *utsname(void)
36{ 68{
37 return &system_utsname; 69 return &current->nsproxy->uts_ns->name;
38} 70}
39 71
40static inline struct new_utsname *init_utsname(void) 72static 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
45extern struct rw_semaphore uts_sem; 79extern struct rw_semaphore uts_sem;
46#endif 80#endif