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>
21 #include <linux/sunrpc/svc_xprt.h>
26 * Declare the debug flags here
28 unsigned int rpc_debug
;
29 EXPORT_SYMBOL_GPL(rpc_debug
);
31 unsigned int nfs_debug
;
32 EXPORT_SYMBOL_GPL(nfs_debug
);
34 unsigned int nfsd_debug
;
35 EXPORT_SYMBOL_GPL(nfsd_debug
);
37 unsigned int nlm_debug
;
38 EXPORT_SYMBOL_GPL(nlm_debug
);
42 static struct ctl_table_header
*sunrpc_table_header
;
43 static ctl_table sunrpc_table
[];
46 rpc_register_sysctl(void)
48 if (!sunrpc_table_header
)
49 sunrpc_table_header
= register_sysctl_table(sunrpc_table
);
53 rpc_unregister_sysctl(void)
55 if (sunrpc_table_header
) {
56 unregister_sysctl_table(sunrpc_table_header
);
57 sunrpc_table_header
= NULL
;
61 static int proc_do_xprt(ctl_table
*table
, int write
,
62 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
67 if ((*ppos
&& !write
) || !*lenp
) {
71 len
= svc_print_xprts(tmpbuf
, sizeof(tmpbuf
));
72 return simple_read_from_buffer(buffer
, *lenp
, ppos
, tmpbuf
, len
);
76 proc_dodebug(ctl_table
*table
, int write
,
77 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
79 char tmpbuf
[20], c
, *s
;
84 if ((*ppos
&& !write
) || !*lenp
) {
92 if (!access_ok(VERIFY_READ
, buffer
, left
))
95 while (left
&& __get_user(c
, p
) >= 0 && isspace(c
))
100 if (left
> sizeof(tmpbuf
) - 1)
102 if (copy_from_user(tmpbuf
, p
, left
))
106 for (s
= tmpbuf
, value
= 0; '0' <= *s
&& *s
<= '9'; s
++, left
--)
107 value
= 10 * value
+ (*s
- '0');
108 if (*s
&& !isspace(*s
))
110 while (left
&& isspace(*s
))
112 *(unsigned int *) table
->data
= value
;
113 /* Display the RPC tasks on writing to rpc_debug */
114 if (strcmp(table
->procname
, "rpc_debug") == 0)
115 rpc_show_tasks(&init_net
);
117 if (!access_ok(VERIFY_WRITE
, buffer
, left
))
119 len
= sprintf(tmpbuf
, "%d", *(unsigned int *) table
->data
);
122 if (__copy_to_user(buffer
, tmpbuf
, len
))
124 if ((left
-= len
) > 0) {
125 if (put_user('\n', (char __user
*)buffer
+ len
))
138 static ctl_table debug_table
[] = {
140 .procname
= "rpc_debug",
142 .maxlen
= sizeof(int),
144 .proc_handler
= proc_dodebug
147 .procname
= "nfs_debug",
149 .maxlen
= sizeof(int),
151 .proc_handler
= proc_dodebug
154 .procname
= "nfsd_debug",
156 .maxlen
= sizeof(int),
158 .proc_handler
= proc_dodebug
161 .procname
= "nlm_debug",
163 .maxlen
= sizeof(int),
165 .proc_handler
= proc_dodebug
168 .procname
= "transports",
171 .proc_handler
= proc_do_xprt
,
176 static ctl_table sunrpc_table
[] = {
178 .procname
= "sunrpc",