aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/util.h')
-rw-r--r--ipc/util.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/ipc/util.h b/ipc/util.h
index c9063267d4f8..30b2a6d7cbed 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -35,6 +35,35 @@ struct ipc_ids {
35 struct idr ipcs_idr; 35 struct idr ipcs_idr;
36}; 36};
37 37
38/*
39 * Structure that holds the parameters needed by the ipc operations
40 * (see after)
41 */
42struct ipc_params {
43 key_t key;
44 int flg;
45 union {
46 size_t size; /* for shared memories */
47 int nsems; /* for semaphores */
48 } u; /* holds the getnew() specific param */
49};
50
51/*
52 * Structure that holds some ipc operations. This structure is used to unify
53 * the calls to sys_msgget(), sys_semget(), sys_shmget()
54 * . routine to call to create a new ipc object. Can be one of newque,
55 * newary, newseg
56 * . routine to call to call to check permissions for a new ipc object.
57 * Can be one of security_msg_associate, security_sem_associate,
58 * security_shm_associate
59 * . routine to call for an extra check if needed
60 */
61struct ipc_ops {
62 int (*getnew) (struct ipc_namespace *, struct ipc_params *);
63 int (*associate) (void *, int);
64 int (*more_checks) (void *, struct ipc_params *);
65};
66
38struct seq_file; 67struct seq_file;
39 68
40void ipc_init_ids(struct ipc_ids *); 69void ipc_init_ids(struct ipc_ids *);
@@ -50,7 +79,6 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
50#define IPC_SHM_IDS 2 79#define IPC_SHM_IDS 2
51 80
52/* must be called with ids->mutex acquired.*/ 81/* must be called with ids->mutex acquired.*/
53struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key);
54int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); 82int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int);
55int ipc_get_maxid(struct ipc_ids *); 83int ipc_get_maxid(struct ipc_ids *);
56 84
@@ -95,5 +123,18 @@ int ipc_parse_version (int *cmd);
95extern void free_msg(struct msg_msg *msg); 123extern void free_msg(struct msg_msg *msg);
96extern struct msg_msg *load_msg(const void __user *src, int len); 124extern struct msg_msg *load_msg(const void __user *src, int len);
97extern int store_msg(void __user *dest, struct msg_msg *msg, int len); 125extern int store_msg(void __user *dest, struct msg_msg *msg, int len);
126extern int ipcget_new(struct ipc_namespace *, struct ipc_ids *,
127 struct ipc_ops *, struct ipc_params *);
128extern int ipcget_public(struct ipc_namespace *, struct ipc_ids *,
129 struct ipc_ops *, struct ipc_params *);
130
131static inline int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
132 struct ipc_ops *ops, struct ipc_params *params)
133{
134 if (params->key == IPC_PRIVATE)
135 return ipcget_new(ns, ids, ops, params);
136 else
137 return ipcget_public(ns, ids, ops, params);
138}
98 139
99#endif 140#endif