2 * Copyright (C) 2007 IBM Corporation
4 * Author: Cedric Le Goater <clg@fr.ibm.com>
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
12 #include <linux/nsproxy.h>
13 #include <linux/ipc_namespace.h>
14 #include <linux/sysctl.h>
16 #ifdef CONFIG_PROC_SYSCTL
17 static void *get_mq(ctl_table *table)
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;
25 static int proc_mq_dointvec(ctl_table *table, int write,
26 void __user *buffer, size_t *lenp, loff_t *ppos)
28 struct ctl_table mq_table;
29 memcpy(&mq_table, table, sizeof(mq_table));
30 mq_table.data = get_mq(table);
32 return proc_dointvec(&mq_table, write, buffer, lenp, ppos);
35 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
36 void __user *buffer, size_t *lenp, loff_t *ppos)
38 struct ctl_table mq_table;
39 memcpy(&mq_table, table, sizeof(mq_table));
40 mq_table.data = get_mq(table);
42 return proc_dointvec_minmax(&mq_table, write, buffer,
46 #define proc_mq_dointvec NULL
47 #define proc_mq_dointvec_minmax NULL
50 static int msg_max_limit_min = MIN_MSGMAX;
51 static int msg_max_limit_max = HARD_MSGMAX;
53 static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
54 static int msg_maxsize_limit_max = HARD_MSGSIZEMAX;
56 static ctl_table mq_sysctls[] = {
58 .procname = "queues_max",
59 .data = &init_ipc_ns.mq_queues_max,
60 .maxlen = sizeof(int),
62 .proc_handler = proc_mq_dointvec,
65 .procname = "msg_max",
66 .data = &init_ipc_ns.mq_msg_max,
67 .maxlen = sizeof(int),
69 .proc_handler = proc_mq_dointvec_minmax,
70 .extra1 = &msg_max_limit_min,
71 .extra2 = &msg_max_limit_max,
74 .procname = "msgsize_max",
75 .data = &init_ipc_ns.mq_msgsize_max,
76 .maxlen = sizeof(int),
78 .proc_handler = proc_mq_dointvec_minmax,
79 .extra1 = &msg_maxsize_limit_min,
80 .extra2 = &msg_maxsize_limit_max,
83 .procname = "msg_default",
84 .data = &init_ipc_ns.mq_msg_default,
85 .maxlen = sizeof(int),
87 .proc_handler = proc_mq_dointvec_minmax,
88 .extra1 = &msg_max_limit_min,
89 .extra2 = &msg_max_limit_max,
92 .procname = "msgsize_default",
93 .data = &init_ipc_ns.mq_msgsize_default,
94 .maxlen = sizeof(int),
96 .proc_handler = proc_mq_dointvec_minmax,
97 .extra1 = &msg_maxsize_limit_min,
98 .extra2 = &msg_maxsize_limit_max,
103 static ctl_table mq_sysctl_dir[] = {
105 .procname = "mqueue",
112 static ctl_table mq_sysctl_root[] = {
116 .child = mq_sysctl_dir,
121 struct ctl_table_header *mq_register_sysctl_table(void)
123 return register_sysctl_table(mq_sysctl_root);