Commit | Line | Data |
---|---|---|
ae5e1b22 PE |
1 | #ifndef __IPC_NAMESPACE_H__ |
2 | #define __IPC_NAMESPACE_H__ | |
3 | ||
4 | #include <linux/err.h> | |
ed2ddbf8 PP |
5 | #include <linux/idr.h> |
6 | #include <linux/rwsem.h> | |
7 | ||
8 | struct ipc_ids { | |
9 | int in_use; | |
10 | unsigned short seq; | |
11 | unsigned short seq_max; | |
12 | struct rw_semaphore rw_mutex; | |
13 | struct idr ipcs_idr; | |
14 | }; | |
ae5e1b22 | 15 | |
ae5e1b22 PE |
16 | struct ipc_namespace { |
17 | struct kref kref; | |
ed2ddbf8 | 18 | struct ipc_ids ids[3]; |
ae5e1b22 PE |
19 | |
20 | int sem_ctls[4]; | |
21 | int used_sems; | |
22 | ||
23 | int msg_ctlmax; | |
24 | int msg_ctlmnb; | |
25 | int msg_ctlmni; | |
26 | atomic_t msg_bytes; | |
27 | atomic_t msg_hdrs; | |
28 | ||
29 | size_t shm_ctlmax; | |
30 | size_t shm_ctlall; | |
31 | int shm_ctlmni; | |
32 | int shm_tot; | |
33 | }; | |
34 | ||
35 | extern struct ipc_namespace init_ipc_ns; | |
4d89dc6a | 36 | extern atomic_t nr_ipc_ns; |
ae5e1b22 PE |
37 | |
38 | #ifdef CONFIG_SYSVIPC | |
39 | #define INIT_IPC_NS(ns) .ns = &init_ipc_ns, | |
40 | #else | |
41 | #define INIT_IPC_NS(ns) | |
42 | #endif | |
43 | ||
44 | #if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS) | |
45 | extern void free_ipc_ns(struct kref *kref); | |
46 | extern struct ipc_namespace *copy_ipcs(unsigned long flags, | |
01b8b07a PP |
47 | struct ipc_namespace *ns); |
48 | extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, | |
49 | void (*free)(struct ipc_namespace *, | |
50 | struct kern_ipc_perm *)); | |
ae5e1b22 PE |
51 | |
52 | static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) | |
53 | { | |
54 | if (ns) | |
55 | kref_get(&ns->kref); | |
56 | return ns; | |
57 | } | |
58 | ||
59 | static inline void put_ipc_ns(struct ipc_namespace *ns) | |
60 | { | |
61 | kref_put(&ns->kref, free_ipc_ns); | |
62 | } | |
63 | #else | |
64 | static inline struct ipc_namespace *copy_ipcs(unsigned long flags, | |
65 | struct ipc_namespace *ns) | |
66 | { | |
67 | if (flags & CLONE_NEWIPC) | |
68 | return ERR_PTR(-EINVAL); | |
69 | ||
70 | return ns; | |
71 | } | |
72 | ||
73 | static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) | |
74 | { | |
75 | return ns; | |
76 | } | |
77 | ||
78 | static inline void put_ipc_ns(struct ipc_namespace *ns) | |
79 | { | |
80 | } | |
81 | #endif | |
82 | #endif |