2 * kernel/vserver/sysctl.c
4 * Virtual Context Support
6 * Copyright (C) 2004-2005 Herbert Pƶtzl
8 * V0.01 basic structure
12 #include <linux/errno.h>
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/ctype.h>
16 #include <linux/sysctl.h>
17 #include <linux/parser.h>
20 #include <asm/uaccess.h>
21 #include <asm/unistd.h>
24 #define CTL_VSERVER 4242 /* unused? */
40 unsigned int vx_debug_switch = 0;
41 unsigned int vx_debug_xid = 0;
42 unsigned int vx_debug_nid = 0;
43 unsigned int vx_debug_net = 0;
44 unsigned int vx_debug_limit = 0;
45 unsigned int vx_debug_cres = 0;
46 unsigned int vx_debug_dlim = 0;
47 unsigned int vx_debug_cvirt = 0;
48 unsigned int vx_debug_misc = 0;
51 static struct ctl_table_header *vserver_table_header;
52 static ctl_table vserver_table[];
55 void vserver_register_sysctl(void)
57 if (!vserver_table_header) {
58 vserver_table_header = register_sysctl_table(vserver_table, 1);
63 void vserver_unregister_sysctl(void)
65 if (vserver_table_header) {
66 unregister_sysctl_table(vserver_table_header);
67 vserver_table_header = NULL;
72 static int proc_dodebug(ctl_table *table, int write,
73 struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
75 char tmpbuf[20], *p, c;
79 if ((*ppos && !write) || !*lenp) {
87 if (!access_ok(VERIFY_READ, buffer, left))
90 while (left && __get_user(c, p) >= 0 && isspace(c))
95 if (left > sizeof(tmpbuf) - 1)
97 if (copy_from_user(tmpbuf, p, left))
101 for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
102 value = 10 * value + (*p - '0');
103 if (*p && !isspace(*p))
105 while (left && isspace(*p))
107 *(unsigned int *) table->data = value;
109 if (!access_ok(VERIFY_WRITE, buffer, left))
111 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
114 if (__copy_to_user(buffer, tmpbuf, len))
116 if ((left -= len) > 0) {
117 if (put_user('\n', (char *)buffer + len))
131 static ctl_table debug_table[] = {
133 .ctl_name = CTL_DEBUG_SWITCH,
134 .procname = "debug_switch",
135 .data = &vx_debug_switch,
136 .maxlen = sizeof(int),
138 .proc_handler = &proc_dodebug
141 .ctl_name = CTL_DEBUG_XID,
142 .procname = "debug_xid",
143 .data = &vx_debug_xid,
144 .maxlen = sizeof(int),
146 .proc_handler = &proc_dodebug
149 .ctl_name = CTL_DEBUG_NID,
150 .procname = "debug_nid",
151 .data = &vx_debug_nid,
152 .maxlen = sizeof(int),
154 .proc_handler = &proc_dodebug
157 .ctl_name = CTL_DEBUG_NET,
158 .procname = "debug_net",
159 .data = &vx_debug_net,
160 .maxlen = sizeof(int),
162 .proc_handler = &proc_dodebug
165 .ctl_name = CTL_DEBUG_LIMIT,
166 .procname = "debug_limit",
167 .data = &vx_debug_limit,
168 .maxlen = sizeof(int),
170 .proc_handler = &proc_dodebug
173 .ctl_name = CTL_DEBUG_CRES,
174 .procname = "debug_cres",
175 .data = &vx_debug_cres,
176 .maxlen = sizeof(int),
178 .proc_handler = &proc_dodebug
181 .ctl_name = CTL_DEBUG_DLIM,
182 .procname = "debug_dlim",
183 .data = &vx_debug_dlim,
184 .maxlen = sizeof(int),
186 .proc_handler = &proc_dodebug
189 .ctl_name = CTL_DEBUG_CVIRT,
190 .procname = "debug_cvirt",
191 .data = &vx_debug_cvirt,
192 .maxlen = sizeof(int),
194 .proc_handler = &proc_dodebug
197 .ctl_name = CTL_DEBUG_MISC,
198 .procname = "debug_misc",
199 .data = &vx_debug_misc,
200 .maxlen = sizeof(int),
202 .proc_handler = &proc_dodebug
207 static ctl_table vserver_table[] = {
209 .ctl_name = CTL_VSERVER,
210 .procname = "vserver",
218 EXPORT_SYMBOL_GPL(vx_debug_switch);
219 EXPORT_SYMBOL_GPL(vx_debug_xid);
220 EXPORT_SYMBOL_GPL(vx_debug_nid);
221 EXPORT_SYMBOL_GPL(vx_debug_net);
222 EXPORT_SYMBOL_GPL(vx_debug_limit);
223 EXPORT_SYMBOL_GPL(vx_debug_cres);
224 EXPORT_SYMBOL_GPL(vx_debug_dlim);
225 EXPORT_SYMBOL_GPL(vx_debug_cvirt);
226 EXPORT_SYMBOL_GPL(vx_debug_misc);