/include/linux/ipc_namespace.h

https://bitbucket.org/thekraven/iscream_thunderc-2.6.35 · C++ Header · 135 lines · 100 code · 28 blank · 7 comment · 2 complexity · f0bdf071ead1b33e49ecdfa8edcf6bd8 MD5 · raw file

  1. #ifndef __IPC_NAMESPACE_H__
  2. #define __IPC_NAMESPACE_H__
  3. #include <linux/err.h>
  4. #include <linux/idr.h>
  5. #include <linux/rwsem.h>
  6. #include <linux/notifier.h>
  7. /*
  8. * ipc namespace events
  9. */
  10. #define IPCNS_MEMCHANGED 0x00000001 /* Notify lowmem size changed */
  11. #define IPCNS_CREATED 0x00000002 /* Notify new ipc namespace created */
  12. #define IPCNS_REMOVED 0x00000003 /* Notify ipc namespace removed */
  13. #define IPCNS_CALLBACK_PRI 0
  14. struct ipc_ids {
  15. int in_use;
  16. unsigned short seq;
  17. unsigned short seq_max;
  18. struct rw_semaphore rw_mutex;
  19. struct idr ipcs_idr;
  20. };
  21. struct ipc_namespace {
  22. atomic_t count;
  23. struct ipc_ids ids[3];
  24. int sem_ctls[4];
  25. int used_sems;
  26. int msg_ctlmax;
  27. int msg_ctlmnb;
  28. int msg_ctlmni;
  29. atomic_t msg_bytes;
  30. atomic_t msg_hdrs;
  31. int auto_msgmni;
  32. size_t shm_ctlmax;
  33. size_t shm_ctlall;
  34. int shm_ctlmni;
  35. int shm_tot;
  36. struct notifier_block ipcns_nb;
  37. /* The kern_mount of the mqueuefs sb. We take a ref on it */
  38. struct vfsmount *mq_mnt;
  39. /* # queues in this ns, protected by mq_lock */
  40. unsigned int mq_queues_count;
  41. /* next fields are set through sysctl */
  42. unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */
  43. unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */
  44. unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */
  45. };
  46. extern struct ipc_namespace init_ipc_ns;
  47. extern atomic_t nr_ipc_ns;
  48. extern spinlock_t mq_lock;
  49. #ifdef CONFIG_SYSVIPC
  50. extern int register_ipcns_notifier(struct ipc_namespace *);
  51. extern int cond_register_ipcns_notifier(struct ipc_namespace *);
  52. extern void unregister_ipcns_notifier(struct ipc_namespace *);
  53. extern int ipcns_notify(unsigned long);
  54. #else /* CONFIG_SYSVIPC */
  55. static inline int register_ipcns_notifier(struct ipc_namespace *ns)
  56. { return 0; }
  57. static inline int cond_register_ipcns_notifier(struct ipc_namespace *ns)
  58. { return 0; }
  59. static inline void unregister_ipcns_notifier(struct ipc_namespace *ns) { }
  60. static inline int ipcns_notify(unsigned long l) { return 0; }
  61. #endif /* CONFIG_SYSVIPC */
  62. #ifdef CONFIG_POSIX_MQUEUE
  63. extern int mq_init_ns(struct ipc_namespace *ns);
  64. /* default values */
  65. #define DFLT_QUEUESMAX 256 /* max number of message queues */
  66. #define DFLT_MSGMAX 10 /* max number of messages in each queue */
  67. #define HARD_MSGMAX (32768*sizeof(void *)/4)
  68. #define DFLT_MSGSIZEMAX 8192 /* max message size */
  69. #else
  70. static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
  71. #endif
  72. #if defined(CONFIG_IPC_NS)
  73. extern struct ipc_namespace *copy_ipcs(unsigned long flags,
  74. struct ipc_namespace *ns);
  75. static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
  76. {
  77. if (ns)
  78. atomic_inc(&ns->count);
  79. return ns;
  80. }
  81. extern void put_ipc_ns(struct ipc_namespace *ns);
  82. #else
  83. static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
  84. struct ipc_namespace *ns)
  85. {
  86. if (flags & CLONE_NEWIPC)
  87. return ERR_PTR(-EINVAL);
  88. return ns;
  89. }
  90. static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
  91. {
  92. return ns;
  93. }
  94. static inline void put_ipc_ns(struct ipc_namespace *ns)
  95. {
  96. }
  97. #endif
  98. #ifdef CONFIG_POSIX_MQUEUE_SYSCTL
  99. struct ctl_table_header;
  100. extern struct ctl_table_header *mq_register_sysctl_table(void);
  101. #else /* CONFIG_POSIX_MQUEUE_SYSCTL */
  102. static inline struct ctl_table_header *mq_register_sysctl_table(void)
  103. {
  104. return NULL;
  105. }
  106. #endif /* CONFIG_POSIX_MQUEUE_SYSCTL */
  107. #endif