Pavel Emelyanov | ae5e1b2 | 2008-02-08 04:18:22 -0800 | [diff] [blame^] | 1 | #ifndef __IPC_NAMESPACE_H__ |
| 2 | #define __IPC_NAMESPACE_H__ |
| 3 | |
| 4 | #include <linux/err.h> |
| 5 | |
| 6 | struct ipc_ids; |
| 7 | struct 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 | |
| 26 | extern 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) |
| 35 | extern void free_ipc_ns(struct kref *kref); |
| 36 | extern struct ipc_namespace *copy_ipcs(unsigned long flags, |
| 37 | struct ipc_namespace *ns); |
| 38 | |
| 39 | static 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 | |
| 46 | static inline void put_ipc_ns(struct ipc_namespace *ns) |
| 47 | { |
| 48 | kref_put(&ns->kref, free_ipc_ns); |
| 49 | } |
| 50 | #else |
| 51 | static 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 | |
| 60 | static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) |
| 61 | { |
| 62 | return ns; |
| 63 | } |
| 64 | |
| 65 | static inline void put_ipc_ns(struct ipc_namespace *ns) |
| 66 | { |
| 67 | } |
| 68 | #endif |
| 69 | #endif |