ipc.h 2.5 KB

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