2 * linux/net/sunrpc/sysctl.c
4 * Sysctl interface to sunrpc module.
6 * I would prefer to register the sunrpc table below sys/net, but that's
7 * impossible at the moment.
10 #include <linux/types.h>
11 #include <linux/linkage.h>
12 #include <linux/ctype.h>
14 #include <linux/sysctl.h>
15 #include <linux/module.h>
17 #include <asm/uaccess.h>
18 #include <linux/sunrpc/types.h>
19 #include <linux/sunrpc/sched.h>
20 #include <linux/sunrpc/stats.h>
23 * Declare the debug flags here
25 unsigned int rpc_debug;
26 EXPORT_SYMBOL_GPL(rpc_debug);
28 unsigned int nfs_debug;
29 EXPORT_SYMBOL_GPL(nfs_debug);
31 unsigned int nfsd_debug;
32 EXPORT_SYMBOL_GPL(nfsd_debug);
34 unsigned int nlm_debug;
35 EXPORT_SYMBOL_GPL(nlm_debug);
39 static struct ctl_table_header *sunrpc_table_header;
40 static ctl_table sunrpc_table[];
43 rpc_register_sysctl(void)
45 if (!sunrpc_table_header)
46 sunrpc_table_header = register_sysctl_table(sunrpc_table);
50 rpc_unregister_sysctl(void)
52 if (sunrpc_table_header) {
53 unregister_sysctl_table(sunrpc_table_header);
54 sunrpc_table_header = NULL;
59 proc_dodebug(ctl_table *table, int write, struct file *file,
60 void __user *buffer, size_t *lenp, loff_t *ppos)
62 char tmpbuf[20], c, *s;
67 if ((*ppos && !write) || !*lenp) {
75 if (!access_ok(VERIFY_READ, buffer, left))
78 while (left && __get_user(c, p) >= 0 && isspace(c))
83 if (left > sizeof(tmpbuf) - 1)
85 if (copy_from_user(tmpbuf, p, left))
89 for (s = tmpbuf, value = 0; '0' <= *s && *s <= '9'; s++, left--)
90 value = 10 * value + (*s - '0');
91 if (*s && !isspace(*s))
93 while (left && isspace(*s))
95 *(unsigned int *) table->data = value;
96 /* Display the RPC tasks on writing to rpc_debug */
97 if (strcmp(table->procname, "rpc_debug") == 0)
100 if (!access_ok(VERIFY_WRITE, buffer, left))
102 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
105 if (__copy_to_user(buffer, tmpbuf, len))
107 if ((left -= len) > 0) {
108 if (put_user('\n', (char __user *)buffer + len))
121 static ctl_table debug_table[] = {
123 .procname = "rpc_debug",
125 .maxlen = sizeof(int),
127 .proc_handler = &proc_dodebug
130 .procname = "nfs_debug",
132 .maxlen = sizeof(int),
134 .proc_handler = &proc_dodebug
137 .procname = "nfsd_debug",
139 .maxlen = sizeof(int),
141 .proc_handler = &proc_dodebug
144 .procname = "nlm_debug",
146 .maxlen = sizeof(int),
148 .proc_handler = &proc_dodebug
153 static ctl_table sunrpc_table[] = {
155 .ctl_name = CTL_SUNRPC,
156 .procname = "sunrpc",