2 * linux/kernel/sysctl.c
4 * Virtual Context Support
6 * Copyright (C) 2004-2005 Herbert Pƶtzl
8 * V0.01 basic structure
12 #include <linux/config.h>
13 #include <linux/errno.h>
14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/ctype.h>
17 #include <linux/sysctl.h>
20 #include <asm/uaccess.h>
21 #include <asm/unistd.h>
24 #define CTL_VSERVER 4242 /* unused? */
37 unsigned int vx_debug_switch = 0;
38 unsigned int vx_debug_xid = 0;
39 unsigned int vx_debug_nid = 0;
40 unsigned int vx_debug_net = 0;
41 unsigned int vx_debug_limit = 0;
42 unsigned int vx_debug_dlim = 0;
43 unsigned int vx_debug_cvirt = 0;
46 static struct ctl_table_header *vserver_table_header;
47 static ctl_table vserver_table[];
50 void vserver_register_sysctl(void)
52 if (!vserver_table_header) {
53 vserver_table_header = register_sysctl_table(vserver_table, 1);
58 void vserver_unregister_sysctl(void)
60 if (vserver_table_header) {
61 unregister_sysctl_table(vserver_table_header);
62 vserver_table_header = NULL;
67 static int proc_dodebug(ctl_table *table, int write,
68 struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
70 char tmpbuf[20], *p, c;
74 if ((*ppos && !write) || !*lenp) {
82 if (!access_ok(VERIFY_READ, buffer, left))
85 while (left && __get_user(c, p) >= 0 && isspace(c))
90 if (left > sizeof(tmpbuf) - 1)
92 if (copy_from_user(tmpbuf, p, left))
96 for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
97 value = 10 * value + (*p - '0');
98 if (*p && !isspace(*p))
100 while (left && isspace(*p))
102 *(unsigned int *) table->data = value;
104 if (!access_ok(VERIFY_WRITE, buffer, left))
106 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
109 if (__copy_to_user(buffer, tmpbuf, len))
111 if ((left -= len) > 0) {
112 if (put_user('\n', (char *)buffer + len))
126 static ctl_table debug_table[] = {
128 .ctl_name = CTL_DEBUG_SWITCH,
129 .procname = "debug_switch",
130 .data = &vx_debug_switch,
131 .maxlen = sizeof(int),
133 .proc_handler = &proc_dodebug
136 .ctl_name = CTL_DEBUG_XID,
137 .procname = "debug_xid",
138 .data = &vx_debug_xid,
139 .maxlen = sizeof(int),
141 .proc_handler = &proc_dodebug
144 .ctl_name = CTL_DEBUG_NID,
145 .procname = "debug_nid",
146 .data = &vx_debug_nid,
147 .maxlen = sizeof(int),
149 .proc_handler = &proc_dodebug
152 .ctl_name = CTL_DEBUG_NET,
153 .procname = "debug_net",
154 .data = &vx_debug_net,
155 .maxlen = sizeof(int),
157 .proc_handler = &proc_dodebug
160 .ctl_name = CTL_DEBUG_LIMIT,
161 .procname = "debug_limit",
162 .data = &vx_debug_limit,
163 .maxlen = sizeof(int),
165 .proc_handler = &proc_dodebug
168 .ctl_name = CTL_DEBUG_DLIM,
169 .procname = "debug_dlim",
170 .data = &vx_debug_dlim,
171 .maxlen = sizeof(int),
173 .proc_handler = &proc_dodebug
176 .ctl_name = CTL_DEBUG_CVIRT,
177 .procname = "debug_cvirt",
178 .data = &vx_debug_cvirt,
179 .maxlen = sizeof(int),
181 .proc_handler = &proc_dodebug
186 static ctl_table vserver_table[] = {
188 .ctl_name = CTL_VSERVER,
189 .procname = "vserver",
197 EXPORT_SYMBOL_GPL(vx_debug_switch);
198 EXPORT_SYMBOL_GPL(vx_debug_xid);
199 EXPORT_SYMBOL_GPL(vx_debug_nid);
200 EXPORT_SYMBOL_GPL(vx_debug_net);
201 EXPORT_SYMBOL_GPL(vx_debug_limit);
202 EXPORT_SYMBOL_GPL(vx_debug_dlim);
203 EXPORT_SYMBOL_GPL(vx_debug_cvirt);