mq_sysctl.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2007 IBM Corporation
  3. *
  4. * Author: Cedric Le Goater <clg@fr.ibm.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, version 2 of the
  9. * License.
  10. */
  11. #include <linux/nsproxy.h>
  12. #include <linux/ipc_namespace.h>
  13. #include <linux/sysctl.h>
  14. #ifdef CONFIG_PROC_SYSCTL
  15. static void *get_mq(ctl_table *table)
  16. {
  17. char *which = table->data;
  18. struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
  19. which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
  20. return which;
  21. }
  22. static int proc_mq_dointvec_minmax(ctl_table *table, int write,
  23. void __user *buffer, size_t *lenp, loff_t *ppos)
  24. {
  25. struct ctl_table mq_table;
  26. memcpy(&mq_table, table, sizeof(mq_table));
  27. mq_table.data = get_mq(table);
  28. return proc_dointvec_minmax(&mq_table, write, buffer,
  29. lenp, ppos);
  30. }
  31. #else
  32. #define proc_mq_dointvec_minmax NULL
  33. #endif
  34. static int msg_queues_limit_min = MIN_QUEUESMAX;
  35. static int msg_queues_limit_max = HARD_QUEUESMAX;
  36. static int msg_max_limit_min = MIN_MSGMAX;
  37. static int msg_max_limit_max = HARD_MSGMAX;
  38. static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
  39. static int msg_maxsize_limit_max = HARD_MSGSIZEMAX;
  40. static ctl_table mq_sysctls[] = {
  41. {
  42. .procname = "queues_max",
  43. .data = &init_ipc_ns.mq_queues_max,
  44. .maxlen = sizeof(int),
  45. .mode = 0644,
  46. .proc_handler = proc_mq_dointvec_minmax,
  47. .extra1 = &msg_queues_limit_min,
  48. .extra2 = &msg_queues_limit_max,
  49. },
  50. {
  51. .procname = "msg_max",
  52. .data = &init_ipc_ns.mq_msg_max,
  53. .maxlen = sizeof(int),
  54. .mode = 0644,
  55. .proc_handler = proc_mq_dointvec_minmax,
  56. .extra1 = &msg_max_limit_min,
  57. .extra2 = &msg_max_limit_max,
  58. },
  59. {
  60. .procname = "msgsize_max",
  61. .data = &init_ipc_ns.mq_msgsize_max,
  62. .maxlen = sizeof(int),
  63. .mode = 0644,
  64. .proc_handler = proc_mq_dointvec_minmax,
  65. .extra1 = &msg_maxsize_limit_min,
  66. .extra2 = &msg_maxsize_limit_max,
  67. },
  68. {
  69. .procname = "msg_default",
  70. .data = &init_ipc_ns.mq_msg_default,
  71. .maxlen = sizeof(int),
  72. .mode = 0644,
  73. .proc_handler = proc_mq_dointvec_minmax,
  74. .extra1 = &msg_max_limit_min,
  75. .extra2 = &msg_max_limit_max,
  76. },
  77. {
  78. .procname = "msgsize_default",
  79. .data = &init_ipc_ns.mq_msgsize_default,
  80. .maxlen = sizeof(int),
  81. .mode = 0644,
  82. .proc_handler = proc_mq_dointvec_minmax,
  83. .extra1 = &msg_maxsize_limit_min,
  84. .extra2 = &msg_maxsize_limit_max,
  85. },
  86. {}
  87. };
  88. static ctl_table mq_sysctl_dir[] = {
  89. {
  90. .procname = "mqueue",
  91. .mode = 0555,
  92. .child = mq_sysctls,
  93. },
  94. {}
  95. };
  96. static ctl_table mq_sysctl_root[] = {
  97. {
  98. .procname = "fs",
  99. .mode = 0555,
  100. .child = mq_sysctl_dir,
  101. },
  102. {}
  103. };
  104. struct ctl_table_header *mq_register_sysctl_table(void)
  105. {
  106. return register_sysctl_table(mq_sysctl_root);
  107. }