diff options
Diffstat (limited to 'include/linux/ipc_namespace.h')
-rw-r--r-- | include/linux/ipc_namespace.h | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index ea330f9e7100..3bf40e246a80 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
@@ -25,7 +25,7 @@ struct ipc_ids { | |||
25 | }; | 25 | }; |
26 | 26 | ||
27 | struct ipc_namespace { | 27 | struct ipc_namespace { |
28 | struct kref kref; | 28 | atomic_t count; |
29 | struct ipc_ids ids[3]; | 29 | struct ipc_ids ids[3]; |
30 | 30 | ||
31 | int sem_ctls[4]; | 31 | int sem_ctls[4]; |
@@ -44,25 +44,57 @@ struct ipc_namespace { | |||
44 | int shm_tot; | 44 | int shm_tot; |
45 | 45 | ||
46 | struct notifier_block ipcns_nb; | 46 | struct notifier_block ipcns_nb; |
47 | |||
48 | /* The kern_mount of the mqueuefs sb. We take a ref on it */ | ||
49 | struct vfsmount *mq_mnt; | ||
50 | |||
51 | /* # queues in this ns, protected by mq_lock */ | ||
52 | unsigned int mq_queues_count; | ||
53 | |||
54 | /* next fields are set through sysctl */ | ||
55 | unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */ | ||
56 | unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ | ||
57 | unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ | ||
58 | |||
47 | }; | 59 | }; |
48 | 60 | ||
49 | extern struct ipc_namespace init_ipc_ns; | 61 | extern struct ipc_namespace init_ipc_ns; |
50 | extern atomic_t nr_ipc_ns; | 62 | extern atomic_t nr_ipc_ns; |
51 | 63 | ||
52 | #ifdef CONFIG_SYSVIPC | 64 | extern spinlock_t mq_lock; |
65 | #if defined(CONFIG_POSIX_MQUEUE) || defined(CONFIG_SYSVIPC) | ||
53 | #define INIT_IPC_NS(ns) .ns = &init_ipc_ns, | 66 | #define INIT_IPC_NS(ns) .ns = &init_ipc_ns, |
67 | #else | ||
68 | #define INIT_IPC_NS(ns) | ||
69 | #endif | ||
54 | 70 | ||
71 | #ifdef CONFIG_SYSVIPC | ||
55 | extern int register_ipcns_notifier(struct ipc_namespace *); | 72 | extern int register_ipcns_notifier(struct ipc_namespace *); |
56 | extern int cond_register_ipcns_notifier(struct ipc_namespace *); | 73 | extern int cond_register_ipcns_notifier(struct ipc_namespace *); |
57 | extern void unregister_ipcns_notifier(struct ipc_namespace *); | 74 | extern void unregister_ipcns_notifier(struct ipc_namespace *); |
58 | extern int ipcns_notify(unsigned long); | 75 | extern int ipcns_notify(unsigned long); |
59 | |||
60 | #else /* CONFIG_SYSVIPC */ | 76 | #else /* CONFIG_SYSVIPC */ |
61 | #define INIT_IPC_NS(ns) | 77 | static inline int register_ipcns_notifier(struct ipc_namespace *ns) |
78 | { return 0; } | ||
79 | static inline int cond_register_ipcns_notifier(struct ipc_namespace *ns) | ||
80 | { return 0; } | ||
81 | static inline void unregister_ipcns_notifier(struct ipc_namespace *ns) { } | ||
82 | static inline int ipcns_notify(unsigned long l) { return 0; } | ||
62 | #endif /* CONFIG_SYSVIPC */ | 83 | #endif /* CONFIG_SYSVIPC */ |
63 | 84 | ||
64 | #if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS) | 85 | #ifdef CONFIG_POSIX_MQUEUE |
65 | extern void free_ipc_ns(struct kref *kref); | 86 | extern int mq_init_ns(struct ipc_namespace *ns); |
87 | /* default values */ | ||
88 | #define DFLT_QUEUESMAX 256 /* max number of message queues */ | ||
89 | #define DFLT_MSGMAX 10 /* max number of messages in each queue */ | ||
90 | #define HARD_MSGMAX (131072/sizeof(void *)) | ||
91 | #define DFLT_MSGSIZEMAX 8192 /* max message size */ | ||
92 | #else | ||
93 | static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; } | ||
94 | #endif | ||
95 | |||
96 | #if defined(CONFIG_IPC_NS) | ||
97 | extern void free_ipc_ns(struct ipc_namespace *ns); | ||
66 | extern struct ipc_namespace *copy_ipcs(unsigned long flags, | 98 | extern struct ipc_namespace *copy_ipcs(unsigned long flags, |
67 | struct ipc_namespace *ns); | 99 | struct ipc_namespace *ns); |
68 | extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, | 100 | extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, |
@@ -72,14 +104,11 @@ extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, | |||
72 | static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) | 104 | static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) |
73 | { | 105 | { |
74 | if (ns) | 106 | if (ns) |
75 | kref_get(&ns->kref); | 107 | atomic_inc(&ns->count); |
76 | return ns; | 108 | return ns; |
77 | } | 109 | } |
78 | 110 | ||
79 | static inline void put_ipc_ns(struct ipc_namespace *ns) | 111 | extern void put_ipc_ns(struct ipc_namespace *ns); |
80 | { | ||
81 | kref_put(&ns->kref, free_ipc_ns); | ||
82 | } | ||
83 | #else | 112 | #else |
84 | static inline struct ipc_namespace *copy_ipcs(unsigned long flags, | 113 | static inline struct ipc_namespace *copy_ipcs(unsigned long flags, |
85 | struct ipc_namespace *ns) | 114 | struct ipc_namespace *ns) |
@@ -99,4 +128,18 @@ static inline void put_ipc_ns(struct ipc_namespace *ns) | |||
99 | { | 128 | { |
100 | } | 129 | } |
101 | #endif | 130 | #endif |
131 | |||
132 | #ifdef CONFIG_POSIX_MQUEUE_SYSCTL | ||
133 | |||
134 | struct ctl_table_header; | ||
135 | extern struct ctl_table_header *mq_register_sysctl_table(void); | ||
136 | |||
137 | #else /* CONFIG_POSIX_MQUEUE_SYSCTL */ | ||
138 | |||
139 | static inline struct ctl_table_header *mq_register_sysctl_table(void) | ||
140 | { | ||
141 | return NULL; | ||
142 | } | ||
143 | |||
144 | #endif /* CONFIG_POSIX_MQUEUE_SYSCTL */ | ||
102 | #endif | 145 | #endif |