2 * linux/kernel/sysctl.c
4 * Virtual Context Support
6 * Copyright (C) 2004 Herbert Pƶtzl
8 * V0.01 basic structure
12 #include <linux/config.h>
13 #include <linux/errno.h>
14 #include <linux/vserver.h>
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/ctype.h>
18 #include <linux/sysctl.h>
21 #include <asm/uaccess.h>
22 #include <asm/unistd.h>
25 #define CTL_VSERVER 4242 /* unused? */
38 unsigned int vx_debug_switch = 0;
39 unsigned int vx_debug_xid = 0;
40 unsigned int vx_debug_nid = 0;
41 unsigned int vx_debug_net = 0;
42 unsigned int vx_debug_limit = 0;
43 unsigned int vx_debug_dlim = 0;
44 unsigned int vx_debug_cvirt = 0;
47 static struct ctl_table_header *vserver_table_header;
48 static ctl_table vserver_table[];
51 void vserver_register_sysctl(void)
53 if (!vserver_table_header) {
54 vserver_table_header = register_sysctl_table(vserver_table, 1);
56 // if (vserver_table[0].de)
57 // vserver_table[0].de->owner = THIS_MODULE;
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_DLIM,
174 .procname = "debug_dlim",
175 .data = &vx_debug_dlim,
176 .maxlen = sizeof(int),
178 .proc_handler = &proc_dodebug
181 .ctl_name = CTL_DEBUG_CVIRT,
182 .procname = "debug_cvirt",
183 .data = &vx_debug_cvirt,
184 .maxlen = sizeof(int),
186 .proc_handler = &proc_dodebug
191 static ctl_table vserver_table[] = {
193 .ctl_name = CTL_VSERVER,
194 .procname = "vserver",
202 EXPORT_SYMBOL_GPL(vx_debug_dlim);