2 * linux/net/sunrpc/sysctl.c
4 * Sysctl interface to sunrpc module. This is for debugging only now.
6 * I would prefer to register the sunrpc table below sys/net, but that's
7 * impossible at the moment.
10 #include <linux/config.h>
11 #include <linux/version.h>
12 #include <linux/types.h>
13 #include <linux/linkage.h>
14 #include <linux/ctype.h>
16 #include <linux/sysctl.h>
17 #include <linux/module.h>
19 #include <asm/uaccess.h>
20 #include <linux/sunrpc/types.h>
21 #include <linux/sunrpc/sched.h>
22 #include <linux/sunrpc/stats.h>
25 * Declare the debug flags here
27 unsigned int rpc_debug;
28 unsigned int nfs_debug;
29 unsigned int nfsd_debug;
30 unsigned int nlm_debug;
34 static struct ctl_table_header *sunrpc_table_header;
35 static ctl_table sunrpc_table[];
38 rpc_register_sysctl(void)
40 if (!sunrpc_table_header) {
41 sunrpc_table_header = register_sysctl_table(sunrpc_table, 1);
43 if (sunrpc_table[0].de)
44 sunrpc_table[0].de->owner = THIS_MODULE;
51 rpc_unregister_sysctl(void)
53 if (sunrpc_table_header) {
54 unregister_sysctl_table(sunrpc_table_header);
55 sunrpc_table_header = NULL;
60 proc_dodebug(ctl_table *table, int write, struct file *file,
61 void *buffer, size_t *lenp)
63 char tmpbuf[20], *p, c;
67 if ((file->f_pos && !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 copy_from_user(tmpbuf, p, left);
88 for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
89 value = 10 * value + (*p - '0');
90 if (*p && !isspace(*p))
92 while (left && isspace(*p))
94 *(unsigned int *) table->data = value;
95 /* Display the RPC tasks on writing to rpc_debug */
96 if (table->ctl_name == CTL_RPCDEBUG) {
100 if (!access_ok(VERIFY_WRITE, buffer, left))
102 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
105 copy_to_user(buffer, tmpbuf, len);
106 if ((left -= len) > 0) {
107 put_user('\n', (char *)buffer + len);
114 file->f_pos += *lenp;
118 #define DIRENTRY(nam1, nam2, child) \
119 {CTL_##nam1, #nam2, NULL, 0, 0555, child }
120 #define DBGENTRY(nam1, nam2) \
121 {CTL_##nam1##DEBUG, #nam2 "_debug", &nam2##_debug, sizeof(int),\
122 0644, NULL, &proc_dodebug}
124 static ctl_table debug_table[] = {
127 DBGENTRY(NFSD, nfsd),
132 static ctl_table sunrpc_table[] = {
133 DIRENTRY(SUNRPC, sunrpc, debug_table),