aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/util.h')
-rw-r--r--ipc/util.h32
1 files changed, 8 insertions, 24 deletions
diff --git a/ipc/util.h b/ipc/util.h
index 333e891bcac..c9063267d4f 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -10,6 +10,8 @@
10#ifndef _IPC_UTIL_H 10#ifndef _IPC_UTIL_H
11#define _IPC_UTIL_H 11#define _IPC_UTIL_H
12 12
13#include <linux/idr.h>
14
13#define USHRT_MAX 0xffff 15#define USHRT_MAX 0xffff
14#define SEQ_MULTIPLIER (IPCMNI) 16#define SEQ_MULTIPLIER (IPCMNI)
15 17
@@ -25,24 +27,17 @@ void sem_exit_ns(struct ipc_namespace *ns);
25void msg_exit_ns(struct ipc_namespace *ns); 27void msg_exit_ns(struct ipc_namespace *ns);
26void shm_exit_ns(struct ipc_namespace *ns); 28void shm_exit_ns(struct ipc_namespace *ns);
27 29
28struct ipc_id_ary {
29 int size;
30 struct kern_ipc_perm *p[0];
31};
32
33struct ipc_ids { 30struct ipc_ids {
34 int in_use; 31 int in_use;
35 int max_id;
36 unsigned short seq; 32 unsigned short seq;
37 unsigned short seq_max; 33 unsigned short seq_max;
38 struct mutex mutex; 34 struct mutex mutex;
39 struct ipc_id_ary nullentry; 35 struct idr ipcs_idr;
40 struct ipc_id_ary* entries;
41}; 36};
42 37
43struct seq_file; 38struct seq_file;
44 39
45void ipc_init_ids(struct ipc_ids *ids, int size); 40void ipc_init_ids(struct ipc_ids *);
46#ifdef CONFIG_PROC_FS 41#ifdef CONFIG_PROC_FS
47void __init ipc_init_proc_interface(const char *path, const char *header, 42void __init ipc_init_proc_interface(const char *path, const char *header,
48 int ids, int (*show)(struct seq_file *, void *)); 43 int ids, int (*show)(struct seq_file *, void *));
@@ -55,11 +50,12 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
55#define IPC_SHM_IDS 2 50#define IPC_SHM_IDS 2
56 51
57/* must be called with ids->mutex acquired.*/ 52/* must be called with ids->mutex acquired.*/
58int ipc_findkey(struct ipc_ids* ids, key_t key); 53struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key);
59int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size); 54int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int);
55int ipc_get_maxid(struct ipc_ids *);
60 56
61/* must be called with both locks acquired. */ 57/* must be called with both locks acquired. */
62struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id); 58void ipc_rmid(struct ipc_ids *, struct kern_ipc_perm *);
63 59
64int ipcperms (struct kern_ipc_perm *ipcp, short flg); 60int ipcperms (struct kern_ipc_perm *ipcp, short flg);
65 61
@@ -79,18 +75,6 @@ void* ipc_rcu_alloc(int size);
79void ipc_rcu_getref(void *ptr); 75void ipc_rcu_getref(void *ptr);
80void ipc_rcu_putref(void *ptr); 76void ipc_rcu_putref(void *ptr);
81 77
82static inline void __ipc_fini_ids(struct ipc_ids *ids,
83 struct ipc_id_ary *entries)
84{
85 if (entries != &ids->nullentry)
86 ipc_rcu_putref(entries);
87}
88
89static inline void ipc_fini_ids(struct ipc_ids *ids)
90{
91 __ipc_fini_ids(ids, ids->entries);
92}
93
94struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id); 78struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
95struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id); 79struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id);
96void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp); 80void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp);