]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - net/sunrpc/sysctl.c
sunrpc: document the rpc_pipefs kernel api
[mirror_ubuntu-bionic-kernel.git] / net / sunrpc / sysctl.c
CommitLineData
1da177e4
LT
1/*
2 * linux/net/sunrpc/sysctl.c
3 *
4 * Sysctl interface to sunrpc module.
5 *
6 * I would prefer to register the sunrpc table below sys/net, but that's
7 * impossible at the moment.
8 */
9
1da177e4
LT
10#include <linux/types.h>
11#include <linux/linkage.h>
12#include <linux/ctype.h>
13#include <linux/fs.h>
14#include <linux/sysctl.h>
15#include <linux/module.h>
16
17#include <asm/uaccess.h>
18#include <linux/sunrpc/types.h>
19#include <linux/sunrpc/sched.h>
20#include <linux/sunrpc/stats.h>
1da177e4
LT
21
22/*
23 * Declare the debug flags here
24 */
25unsigned int rpc_debug;
26unsigned int nfs_debug;
27unsigned int nfsd_debug;
28unsigned int nlm_debug;
29
30#ifdef RPC_DEBUG
31
32static struct ctl_table_header *sunrpc_table_header;
33static ctl_table sunrpc_table[];
34
35void
36rpc_register_sysctl(void)
37{
2b1bec5f 38 if (!sunrpc_table_header)
0b4d4147 39 sunrpc_table_header = register_sysctl_table(sunrpc_table);
1da177e4
LT
40}
41
42void
43rpc_unregister_sysctl(void)
44{
45 if (sunrpc_table_header) {
46 unregister_sysctl_table(sunrpc_table_header);
47 sunrpc_table_header = NULL;
48 }
49}
50
51static int
52proc_dodebug(ctl_table *table, int write, struct file *file,
53 void __user *buffer, size_t *lenp, loff_t *ppos)
54{
55 char tmpbuf[20], c, *s;
56 char __user *p;
57 unsigned int value;
58 size_t left, len;
59
60 if ((*ppos && !write) || !*lenp) {
61 *lenp = 0;
62 return 0;
63 }
64
65 left = *lenp;
66
67 if (write) {
68 if (!access_ok(VERIFY_READ, buffer, left))
69 return -EFAULT;
70 p = buffer;
71 while (left && __get_user(c, p) >= 0 && isspace(c))
72 left--, p++;
73 if (!left)
74 goto done;
75
76 if (left > sizeof(tmpbuf) - 1)
77 return -EINVAL;
78 if (copy_from_user(tmpbuf, p, left))
79 return -EFAULT;
80 tmpbuf[left] = '\0';
81
82 for (s = tmpbuf, value = 0; '0' <= *s && *s <= '9'; s++, left--)
83 value = 10 * value + (*s - '0');
84 if (*s && !isspace(*s))
85 return -EINVAL;
86 while (left && isspace(*s))
87 left--, s++;
88 *(unsigned int *) table->data = value;
89 /* Display the RPC tasks on writing to rpc_debug */
bc2a3f86 90 if (strcmp(table->procname, "rpc_debug") == 0)
1da177e4 91 rpc_show_tasks();
1da177e4
LT
92 } else {
93 if (!access_ok(VERIFY_WRITE, buffer, left))
94 return -EFAULT;
95 len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
96 if (len > left)
97 len = left;
98 if (__copy_to_user(buffer, tmpbuf, len))
99 return -EFAULT;
100 if ((left -= len) > 0) {
101 if (put_user('\n', (char __user *)buffer + len))
102 return -EFAULT;
103 left--;
104 }
105 }
106
107done:
108 *lenp -= left;
109 *ppos += *lenp;
110 return 0;
111}
112
a246b010 113
1da177e4
LT
114static ctl_table debug_table[] = {
115 {
1da177e4
LT
116 .procname = "rpc_debug",
117 .data = &rpc_debug,
118 .maxlen = sizeof(int),
119 .mode = 0644,
120 .proc_handler = &proc_dodebug
cca5172a 121 },
1da177e4 122 {
1da177e4
LT
123 .procname = "nfs_debug",
124 .data = &nfs_debug,
125 .maxlen = sizeof(int),
126 .mode = 0644,
127 .proc_handler = &proc_dodebug
cca5172a 128 },
1da177e4 129 {
1da177e4
LT
130 .procname = "nfsd_debug",
131 .data = &nfsd_debug,
132 .maxlen = sizeof(int),
133 .mode = 0644,
134 .proc_handler = &proc_dodebug
cca5172a 135 },
1da177e4 136 {
1da177e4
LT
137 .procname = "nlm_debug",
138 .data = &nlm_debug,
139 .maxlen = sizeof(int),
140 .mode = 0644,
141 .proc_handler = &proc_dodebug
cca5172a 142 },
1da177e4
LT
143 { .ctl_name = 0 }
144};
145
146static ctl_table sunrpc_table[] = {
147 {
148 .ctl_name = CTL_SUNRPC,
149 .procname = "sunrpc",
150 .mode = 0555,
151 .child = debug_table
152 },
153 { .ctl_name = 0 }
154};
155
156#endif