]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_IPC_H |
2 | #define _LINUX_IPC_H | |
3 | ||
4 | #include <linux/types.h> | |
25b21cb2 | 5 | #include <linux/kref.h> |
1da177e4 LT |
6 | |
7 | #define IPC_PRIVATE ((__kernel_key_t) 0) | |
8 | ||
9 | /* Obsolete, used only for backwards compatibility and libc5 compiles */ | |
10 | struct ipc_perm | |
11 | { | |
12 | __kernel_key_t key; | |
13 | __kernel_uid_t uid; | |
14 | __kernel_gid_t gid; | |
15 | __kernel_uid_t cuid; | |
16 | __kernel_gid_t cgid; | |
17 | __kernel_mode_t mode; | |
18 | unsigned short seq; | |
19 | }; | |
20 | ||
21 | /* Include the definition of ipc64_perm */ | |
22 | #include <asm/ipcbuf.h> | |
23 | ||
24 | /* resource get request flags */ | |
25 | #define IPC_CREAT 00001000 /* create if key is nonexistent */ | |
26 | #define IPC_EXCL 00002000 /* fail if key exists */ | |
27 | #define IPC_NOWAIT 00004000 /* return error on wait */ | |
28 | ||
29 | /* these fields are used by the DIPC package so the kernel as standard | |
30 | should avoid using them if possible */ | |
31 | ||
32 | #define IPC_DIPC 00010000 /* make it distributed */ | |
33 | #define IPC_OWN 00020000 /* this machine is the DIPC owner */ | |
34 | ||
35 | /* | |
36 | * Control commands used with semctl, msgctl and shmctl | |
37 | * see also specific commands in sem.h, msg.h and shm.h | |
38 | */ | |
39 | #define IPC_RMID 0 /* remove resource */ | |
40 | #define IPC_SET 1 /* set ipc_perm options */ | |
41 | #define IPC_STAT 2 /* get ipc_perm options */ | |
42 | #define IPC_INFO 3 /* see ipcs */ | |
43 | ||
44 | /* | |
45 | * Version flags for semctl, msgctl, and shmctl commands | |
46 | * These are passed as bitflags or-ed with the actual command | |
47 | */ | |
48 | #define IPC_OLD 0 /* Old version (no 32-bit UID support on many | |
49 | architectures) */ | |
50 | #define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger | |
51 | message sizes, etc. */ | |
52 | ||
53 | #ifdef __KERNEL__ | |
54 | ||
55 | #define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */ | |
56 | ||
57 | /* used by in-kernel data structures */ | |
58 | struct kern_ipc_perm | |
59 | { | |
60 | spinlock_t lock; | |
61 | int deleted; | |
62 | key_t key; | |
63 | uid_t uid; | |
64 | gid_t gid; | |
65 | uid_t cuid; | |
66 | gid_t cgid; | |
67 | mode_t mode; | |
68 | unsigned long seq; | |
69 | void *security; | |
70 | }; | |
71 | ||
25b21cb2 KK |
72 | struct ipc_ids; |
73 | struct ipc_namespace { | |
74 | struct kref kref; | |
75 | struct ipc_ids *ids[3]; | |
76 | ||
77 | int sem_ctls[4]; | |
78 | int used_sems; | |
79 | ||
80 | int msg_ctlmax; | |
81 | int msg_ctlmnb; | |
82 | int msg_ctlmni; | |
83 | ||
84 | size_t shm_ctlmax; | |
85 | size_t shm_ctlall; | |
86 | int shm_ctlmni; | |
87 | int shm_tot; | |
88 | }; | |
89 | ||
90 | extern struct ipc_namespace init_ipc_ns; | |
73ea4130 KK |
91 | |
92 | #ifdef CONFIG_SYSVIPC | |
93 | #define INIT_IPC_NS(ns) .ns = &init_ipc_ns, | |
94 | #else | |
95 | #define INIT_IPC_NS(ns) | |
96 | #endif | |
97 | ||
98 | #ifdef CONFIG_IPC_NS | |
25b21cb2 KK |
99 | extern void free_ipc_ns(struct kref *kref); |
100 | extern int copy_ipcs(unsigned long flags, struct task_struct *tsk); | |
101 | extern int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns); | |
73ea4130 KK |
102 | #else |
103 | static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk) | |
104 | { | |
105 | return 0; | |
106 | } | |
107 | #endif | |
25b21cb2 KK |
108 | |
109 | static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) | |
110 | { | |
73ea4130 | 111 | #ifdef CONFIG_IPC_NS |
25b21cb2 KK |
112 | if (ns) |
113 | kref_get(&ns->kref); | |
73ea4130 | 114 | #endif |
25b21cb2 KK |
115 | return ns; |
116 | } | |
117 | ||
118 | static inline void put_ipc_ns(struct ipc_namespace *ns) | |
119 | { | |
73ea4130 | 120 | #ifdef CONFIG_IPC_NS |
25b21cb2 | 121 | kref_put(&ns->kref, free_ipc_ns); |
73ea4130 | 122 | #endif |
25b21cb2 KK |
123 | } |
124 | ||
1da177e4 LT |
125 | #endif /* __KERNEL__ */ |
126 | ||
127 | #endif /* _LINUX_IPC_H */ | |
128 | ||
129 |