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? */
34 unsigned int vx_debug_switch = 0;
35 unsigned int vx_debug_limit = 0;
36 unsigned int vx_debug_dlimit = 0;
39 static struct ctl_table_header *vserver_table_header;
40 static ctl_table vserver_table[];
43 void vserver_register_sysctl(void)
45 if (!vserver_table_header) {
46 vserver_table_header = register_sysctl_table(vserver_table, 1);
48 // if (vserver_table[0].de)
49 // vserver_table[0].de->owner = THIS_MODULE;
55 void vserver_unregister_sysctl(void)
57 if (vserver_table_header) {
58 unregister_sysctl_table(vserver_table_header);
59 vserver_table_header = NULL;
64 static int proc_dodebug(ctl_table *table, int write,
65 struct file *file, void *buffer, size_t *lenp)
67 char tmpbuf[20], *p, c;
71 if ((file->f_pos && !write) || !*lenp) {
79 if (!access_ok(VERIFY_READ, buffer, left))
82 while (left && __get_user(c, p) >= 0 && isspace(c))
87 if (left > sizeof(tmpbuf) - 1)
89 if (copy_from_user(tmpbuf, p, left))
93 for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
94 value = 10 * value + (*p - '0');
95 if (*p && !isspace(*p))
97 while (left && isspace(*p))
99 *(unsigned int *) table->data = value;
101 if (!access_ok(VERIFY_WRITE, buffer, left))
103 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
106 if (__copy_to_user(buffer, tmpbuf, len))
108 if ((left -= len) > 0) {
109 if (put_user('\n', (char *)buffer + len))
117 file->f_pos += *lenp;
123 static ctl_table debug_table[] = {
125 .ctl_name = CTL_DEBUG_SWITCH,
126 .procname = "debug_switch",
127 .data = &vx_debug_switch,
128 .maxlen = sizeof(int),
130 .proc_handler = &proc_dodebug
133 .ctl_name = CTL_DEBUG_LIMIT,
134 .procname = "debug_limit",
135 .data = &vx_debug_limit,
136 .maxlen = sizeof(int),
138 .proc_handler = &proc_dodebug
141 .ctl_name = CTL_DEBUG_DLIMIT,
142 .procname = "debug_dlimit",
143 .data = &vx_debug_dlimit,
144 .maxlen = sizeof(int),
146 .proc_handler = &proc_dodebug
151 static ctl_table vserver_table[] = {
153 .ctl_name = CTL_VSERVER,
154 .procname = "vserver",