blob: e22336a09b4a7932c0a5de4615fb4c7de9a98687 [file] [log] [blame]
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -07001/*
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
12#include <linux/nsproxy.h>
13#include <linux/ipc_namespace.h>
14#include <linux/sysctl.h>
15
Geert Uytterhoevenf26ec5b2009-04-13 14:39:48 -070016#ifdef CONFIG_PROC_SYSCTL
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070017static void *get_mq(ctl_table *table)
18{
19 char *which = table->data;
20 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
21 which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
22 return which;
23}
24
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070025static int proc_mq_dointvec_minmax(ctl_table *table, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070026 void __user *buffer, size_t *lenp, loff_t *ppos)
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070027{
28 struct ctl_table mq_table;
29 memcpy(&mq_table, table, sizeof(mq_table));
30 mq_table.data = get_mq(table);
31
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070032 return proc_dointvec_minmax(&mq_table, write, buffer,
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070033 lenp, ppos);
34}
35#else
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070036#define proc_mq_dointvec_minmax NULL
37#endif
38
Doug Ledford93e6f112012-05-31 16:26:28 -070039static int msg_queues_limit_min = MIN_QUEUESMAX;
40static int msg_queues_limit_max = HARD_QUEUESMAX;
41
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070042static int msg_max_limit_min = MIN_MSGMAX;
Doug Ledford93e6f112012-05-31 16:26:28 -070043static int msg_max_limit_max = HARD_MSGMAX;
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070044
45static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
Doug Ledford93e6f112012-05-31 16:26:28 -070046static int msg_maxsize_limit_max = HARD_MSGSIZEMAX;
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070047
48static ctl_table mq_sysctls[] = {
49 {
50 .procname = "queues_max",
51 .data = &init_ipc_ns.mq_queues_max,
52 .maxlen = sizeof(int),
53 .mode = 0644,
Doug Ledford93e6f112012-05-31 16:26:28 -070054 .proc_handler = proc_mq_dointvec_minmax,
55 .extra1 = &msg_queues_limit_min,
56 .extra2 = &msg_queues_limit_max,
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070057 },
58 {
59 .procname = "msg_max",
60 .data = &init_ipc_ns.mq_msg_max,
61 .maxlen = sizeof(int),
62 .mode = 0644,
63 .proc_handler = proc_mq_dointvec_minmax,
64 .extra1 = &msg_max_limit_min,
65 .extra2 = &msg_max_limit_max,
66 },
67 {
68 .procname = "msgsize_max",
69 .data = &init_ipc_ns.mq_msgsize_max,
70 .maxlen = sizeof(int),
71 .mode = 0644,
72 .proc_handler = proc_mq_dointvec_minmax,
73 .extra1 = &msg_maxsize_limit_min,
74 .extra2 = &msg_maxsize_limit_max,
75 },
Eric W. Biederman2bc46572009-04-03 02:51:10 -070076 {}
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070077};
78
79static ctl_table mq_sysctl_dir[] = {
80 {
81 .procname = "mqueue",
82 .mode = 0555,
83 .child = mq_sysctls,
84 },
Eric W. Biederman2bc46572009-04-03 02:51:10 -070085 {}
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070086};
87
88static ctl_table mq_sysctl_root[] = {
89 {
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070090 .procname = "fs",
91 .mode = 0555,
92 .child = mq_sysctl_dir,
93 },
Eric W. Biederman2bc46572009-04-03 02:51:10 -070094 {}
Serge E. Hallynbdc8e5f2009-04-06 19:01:11 -070095};
96
97struct ctl_table_header *mq_register_sysctl_table(void)
98{
99 return register_sysctl_table(mq_sysctl_root);
100}