Blame view

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