aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-02-08 07:18:22 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:23 -0500
commitae5e1b22f17983da929a0d0178896269e19da186 (patch)
treee9937e2060167a430cf90955327d1a5a2e7b2303 /include/linux
parent58bfdd6deeec02b73691ea2c951a3c5d743bca63 (diff)
namespaces: move the IPC namespace under IPC_NS option
Currently the IPC namespace management code is spread over the ipc/*.c files. I moved this code into ipc/namespace.c file which is compiled out when needed. The linux/ipc_namespace.h file is used to store the prototypes of the functions in namespace.c and the stubs for NAMESPACES=n case. This is done so, because the stub for copy_ipc_namespace requires the knowledge of the CLONE_NEWIPC flag, which is in sched.h. But the linux/ipc.h file itself in included into many many .c files via the sys.h->sem.h sequence so adding the sched.h into it will make all these .c depend on sched.h which is not that good. On the other hand the knowledge about the namespaces stuff is required in 4 .c files only. Besides, this patch compiles out some auxiliary functions from ipc/sem.c, msg.c and shm.c files. It turned out that moving these functions into namespaces.c is not that easy because they use many other calls and macros from the original file. Moving them would make this patch complicated. On the other hand all these functions can be consolidated, so I will send a separate patch doing this a bit later. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Kirill Korotaev <dev@sw.ru> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ipc.h52
-rw-r--r--include/linux/ipc_namespace.h69
2 files changed, 69 insertions, 52 deletions
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index 408696ea5189..b8826107b518 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -100,58 +100,6 @@ struct kern_ipc_perm
100 void *security; 100 void *security;
101}; 101};
102 102
103struct ipc_ids;
104struct ipc_namespace {
105 struct kref kref;
106 struct ipc_ids *ids[3];
107
108 int sem_ctls[4];
109 int used_sems;
110
111 int msg_ctlmax;
112 int msg_ctlmnb;
113 int msg_ctlmni;
114 atomic_t msg_bytes;
115 atomic_t msg_hdrs;
116
117 size_t shm_ctlmax;
118 size_t shm_ctlall;
119 int shm_ctlmni;
120 int shm_tot;
121};
122
123extern struct ipc_namespace init_ipc_ns;
124
125#ifdef CONFIG_SYSVIPC
126#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
127extern void free_ipc_ns(struct kref *kref);
128extern struct ipc_namespace *copy_ipcs(unsigned long flags,
129 struct ipc_namespace *ns);
130#else
131#define INIT_IPC_NS(ns)
132static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
133 struct ipc_namespace *ns)
134{
135 return ns;
136}
137#endif
138
139static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
140{
141#ifdef CONFIG_SYSVIPC
142 if (ns)
143 kref_get(&ns->kref);
144#endif
145 return ns;
146}
147
148static inline void put_ipc_ns(struct ipc_namespace *ns)
149{
150#ifdef CONFIG_SYSVIPC
151 kref_put(&ns->kref, free_ipc_ns);
152#endif
153}
154
155#endif /* __KERNEL__ */ 103#endif /* __KERNEL__ */
156 104
157#endif /* _LINUX_IPC_H */ 105#endif /* _LINUX_IPC_H */
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
new file mode 100644
index 000000000000..a491fc9dd231
--- /dev/null
+++ b/include/linux/ipc_namespace.h
@@ -0,0 +1,69 @@
1#ifndef __IPC_NAMESPACE_H__
2#define __IPC_NAMESPACE_H__
3
4#include <linux/err.h>
5
6struct ipc_ids;
7struct ipc_namespace {
8 struct kref kref;
9 struct ipc_ids *ids[3];
10
11 int sem_ctls[4];
12 int used_sems;
13
14 int msg_ctlmax;
15 int msg_ctlmnb;
16 int msg_ctlmni;
17 atomic_t msg_bytes;
18 atomic_t msg_hdrs;
19
20 size_t shm_ctlmax;
21 size_t shm_ctlall;
22 int shm_ctlmni;
23 int shm_tot;
24};
25
26extern struct ipc_namespace init_ipc_ns;
27
28#ifdef CONFIG_SYSVIPC
29#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
30#else
31#define INIT_IPC_NS(ns)
32#endif
33
34#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS)
35extern void free_ipc_ns(struct kref *kref);
36extern struct ipc_namespace *copy_ipcs(unsigned long flags,
37 struct ipc_namespace *ns);
38
39static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
40{
41 if (ns)
42 kref_get(&ns->kref);
43 return ns;
44}
45
46static inline void put_ipc_ns(struct ipc_namespace *ns)
47{
48 kref_put(&ns->kref, free_ipc_ns);
49}
50#else
51static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
52 struct ipc_namespace *ns)
53{
54 if (flags & CLONE_NEWIPC)
55 return ERR_PTR(-EINVAL);
56
57 return ns;
58}
59
60static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
61{
62 return ns;
63}
64
65static inline void put_ipc_ns(struct ipc_namespace *ns)
66{
67}
68#endif
69#endif