[PATCH] ipw2100: Fix a gcc compile warning
[linux-2.6/verdex.git] / net / sunrpc / sysctl.c
blob1065904841fd5796b9482a994f3caa3bcc9eaaea
1 /*
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.
8 */
10 #include <linux/config.h>
11 #include <linux/types.h>
12 #include <linux/linkage.h>
13 #include <linux/ctype.h>
14 #include <linux/fs.h>
15 #include <linux/sysctl.h>
16 #include <linux/module.h>
18 #include <asm/uaccess.h>
19 #include <linux/sunrpc/types.h>
20 #include <linux/sunrpc/sched.h>
21 #include <linux/sunrpc/stats.h>
22 #include <linux/sunrpc/xprt.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;
32 #ifdef RPC_DEBUG
34 static struct ctl_table_header *sunrpc_table_header;
35 static ctl_table sunrpc_table[];
37 void
38 rpc_register_sysctl(void)
40 if (!sunrpc_table_header) {
41 sunrpc_table_header = register_sysctl_table(sunrpc_table, 1);
42 #ifdef CONFIG_PROC_FS
43 if (sunrpc_table[0].de)
44 sunrpc_table[0].de->owner = THIS_MODULE;
45 #endif
50 void
51 rpc_unregister_sysctl(void)
53 if (sunrpc_table_header) {
54 unregister_sysctl_table(sunrpc_table_header);
55 sunrpc_table_header = NULL;
59 static int
60 proc_dodebug(ctl_table *table, int write, struct file *file,
61 void __user *buffer, size_t *lenp, loff_t *ppos)
63 char tmpbuf[20], c, *s;
64 char __user *p;
65 unsigned int value;
66 size_t left, len;
68 if ((*ppos && !write) || !*lenp) {
69 *lenp = 0;
70 return 0;
73 left = *lenp;
75 if (write) {
76 if (!access_ok(VERIFY_READ, buffer, left))
77 return -EFAULT;
78 p = buffer;
79 while (left && __get_user(c, p) >= 0 && isspace(c))
80 left--, p++;
81 if (!left)
82 goto done;
84 if (left > sizeof(tmpbuf) - 1)
85 return -EINVAL;
86 if (copy_from_user(tmpbuf, p, left))
87 return -EFAULT;
88 tmpbuf[left] = '\0';
90 for (s = tmpbuf, value = 0; '0' <= *s && *s <= '9'; s++, left--)
91 value = 10 * value + (*s - '0');
92 if (*s && !isspace(*s))
93 return -EINVAL;
94 while (left && isspace(*s))
95 left--, s++;
96 *(unsigned int *) table->data = value;
97 /* Display the RPC tasks on writing to rpc_debug */
98 if (table->ctl_name == CTL_RPCDEBUG) {
99 rpc_show_tasks();
101 } else {
102 if (!access_ok(VERIFY_WRITE, buffer, left))
103 return -EFAULT;
104 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
105 if (len > left)
106 len = left;
107 if (__copy_to_user(buffer, tmpbuf, len))
108 return -EFAULT;
109 if ((left -= len) > 0) {
110 if (put_user('\n', (char __user *)buffer + len))
111 return -EFAULT;
112 left--;
116 done:
117 *lenp -= left;
118 *ppos += *lenp;
119 return 0;
123 static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
124 static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
125 static unsigned int xprt_min_resvport_limit = RPC_MIN_RESVPORT;
126 static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
128 static ctl_table debug_table[] = {
130 .ctl_name = CTL_RPCDEBUG,
131 .procname = "rpc_debug",
132 .data = &rpc_debug,
133 .maxlen = sizeof(int),
134 .mode = 0644,
135 .proc_handler = &proc_dodebug
138 .ctl_name = CTL_NFSDEBUG,
139 .procname = "nfs_debug",
140 .data = &nfs_debug,
141 .maxlen = sizeof(int),
142 .mode = 0644,
143 .proc_handler = &proc_dodebug
146 .ctl_name = CTL_NFSDDEBUG,
147 .procname = "nfsd_debug",
148 .data = &nfsd_debug,
149 .maxlen = sizeof(int),
150 .mode = 0644,
151 .proc_handler = &proc_dodebug
154 .ctl_name = CTL_NLMDEBUG,
155 .procname = "nlm_debug",
156 .data = &nlm_debug,
157 .maxlen = sizeof(int),
158 .mode = 0644,
159 .proc_handler = &proc_dodebug
162 .ctl_name = CTL_SLOTTABLE_UDP,
163 .procname = "udp_slot_table_entries",
164 .data = &xprt_udp_slot_table_entries,
165 .maxlen = sizeof(unsigned int),
166 .mode = 0644,
167 .proc_handler = &proc_dointvec_minmax,
168 .strategy = &sysctl_intvec,
169 .extra1 = &min_slot_table_size,
170 .extra2 = &max_slot_table_size
173 .ctl_name = CTL_SLOTTABLE_TCP,
174 .procname = "tcp_slot_table_entries",
175 .data = &xprt_tcp_slot_table_entries,
176 .maxlen = sizeof(unsigned int),
177 .mode = 0644,
178 .proc_handler = &proc_dointvec_minmax,
179 .strategy = &sysctl_intvec,
180 .extra1 = &min_slot_table_size,
181 .extra2 = &max_slot_table_size
184 .ctl_name = CTL_MIN_RESVPORT,
185 .procname = "min_resvport",
186 .data = &xprt_min_resvport,
187 .maxlen = sizeof(unsigned int),
188 .mode = 0644,
189 .proc_handler = &proc_dointvec_minmax,
190 .strategy = &sysctl_intvec,
191 .extra1 = &xprt_min_resvport_limit,
192 .extra2 = &xprt_max_resvport_limit
195 .ctl_name = CTL_MAX_RESVPORT,
196 .procname = "max_resvport",
197 .data = &xprt_max_resvport,
198 .maxlen = sizeof(unsigned int),
199 .mode = 0644,
200 .proc_handler = &proc_dointvec_minmax,
201 .strategy = &sysctl_intvec,
202 .extra1 = &xprt_min_resvport_limit,
203 .extra2 = &xprt_max_resvport_limit
205 { .ctl_name = 0 }
208 static ctl_table sunrpc_table[] = {
210 .ctl_name = CTL_SUNRPC,
211 .procname = "sunrpc",
212 .mode = 0555,
213 .child = debug_table
215 { .ctl_name = 0 }
218 #endif