Blame view
net/sunrpc/sysctl.c
3.6 KB
1da177e4c
|
1 2 3 4 5 6 7 8 |
/* * linux/net/sunrpc/sysctl.c * * Sysctl interface to sunrpc module. * * I would prefer to register the sunrpc table below sys/net, but that's * impossible at the moment. */ |
1da177e4c
|
9 10 11 12 13 14 15 16 17 18 19 |
#include <linux/types.h> #include <linux/linkage.h> #include <linux/ctype.h> #include <linux/fs.h> #include <linux/sysctl.h> #include <linux/module.h> #include <asm/uaccess.h> #include <linux/sunrpc/types.h> #include <linux/sunrpc/sched.h> #include <linux/sunrpc/stats.h> |
dc9a16e49
|
20 |
#include <linux/sunrpc/svc_xprt.h> |
1da177e4c
|
21 |
|
70abc49b4
|
22 |
#include "netns.h" |
1da177e4c
|
23 24 25 26 |
/* * Declare the debug flags here */ unsigned int rpc_debug; |
e8914c65f
|
27 |
EXPORT_SYMBOL_GPL(rpc_debug); |
a6eaf8bdf
|
28 |
|
1da177e4c
|
29 |
unsigned int nfs_debug; |
e8914c65f
|
30 |
EXPORT_SYMBOL_GPL(nfs_debug); |
a6eaf8bdf
|
31 |
|
1da177e4c
|
32 |
unsigned int nfsd_debug; |
e8914c65f
|
33 |
EXPORT_SYMBOL_GPL(nfsd_debug); |
a6eaf8bdf
|
34 |
|
1da177e4c
|
35 |
unsigned int nlm_debug; |
e8914c65f
|
36 |
EXPORT_SYMBOL_GPL(nlm_debug); |
1da177e4c
|
37 |
|
f895b252d
|
38 |
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
1da177e4c
|
39 40 |
static struct ctl_table_header *sunrpc_table_header; |
fe2c6338f
|
41 |
static struct ctl_table sunrpc_table[]; |
1da177e4c
|
42 43 44 45 |
void rpc_register_sysctl(void) { |
2b1bec5f5
|
46 |
if (!sunrpc_table_header) |
0b4d41471
|
47 |
sunrpc_table_header = register_sysctl_table(sunrpc_table); |
1da177e4c
|
48 49 50 51 52 53 54 55 56 57 |
} void rpc_unregister_sysctl(void) { if (sunrpc_table_header) { unregister_sysctl_table(sunrpc_table_header); sunrpc_table_header = NULL; } } |
fe2c6338f
|
58 |
static int proc_do_xprt(struct ctl_table *table, int write, |
dc9a16e49
|
59 60 61 |
void __user *buffer, size_t *lenp, loff_t *ppos) { char tmpbuf[256]; |
27df6f25f
|
62 |
size_t len; |
dc9a16e49
|
63 64 65 66 |
if ((*ppos && !write) || !*lenp) { *lenp = 0; return 0; } |
27df6f25f
|
67 68 |
len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); return simple_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); |
dc9a16e49
|
69 |
} |
1da177e4c
|
70 |
static int |
fe2c6338f
|
71 |
proc_dodebug(struct ctl_table *table, int write, |
1da177e4c
|
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
void __user *buffer, size_t *lenp, loff_t *ppos) { char tmpbuf[20], c, *s; char __user *p; unsigned int value; size_t left, len; if ((*ppos && !write) || !*lenp) { *lenp = 0; return 0; } left = *lenp; if (write) { if (!access_ok(VERIFY_READ, buffer, left)) return -EFAULT; p = buffer; while (left && __get_user(c, p) >= 0 && isspace(c)) left--, p++; if (!left) goto done; if (left > sizeof(tmpbuf) - 1) return -EINVAL; if (copy_from_user(tmpbuf, p, left)) return -EFAULT; tmpbuf[left] = '\0'; for (s = tmpbuf, value = 0; '0' <= *s && *s <= '9'; s++, left--) value = 10 * value + (*s - '0'); if (*s && !isspace(*s)) return -EINVAL; while (left && isspace(*s)) left--, s++; *(unsigned int *) table->data = value; /* Display the RPC tasks on writing to rpc_debug */ |
bc2a3f86f
|
109 |
if (strcmp(table->procname, "rpc_debug") == 0) |
70abc49b4
|
110 |
rpc_show_tasks(&init_net); |
1da177e4c
|
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
} else { if (!access_ok(VERIFY_WRITE, buffer, left)) return -EFAULT; len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data); if (len > left) len = left; if (__copy_to_user(buffer, tmpbuf, len)) return -EFAULT; if ((left -= len) > 0) { if (put_user(' ', (char __user *)buffer + len)) return -EFAULT; left--; } } done: *lenp -= left; *ppos += *lenp; return 0; } |
a246b0105
|
132 |
|
fe2c6338f
|
133 |
static struct ctl_table debug_table[] = { |
1da177e4c
|
134 |
{ |
1da177e4c
|
135 136 137 138 |
.procname = "rpc_debug", .data = &rpc_debug, .maxlen = sizeof(int), .mode = 0644, |
6d4561110
|
139 |
.proc_handler = proc_dodebug |
cca5172a7
|
140 |
}, |
1da177e4c
|
141 |
{ |
1da177e4c
|
142 143 144 145 |
.procname = "nfs_debug", .data = &nfs_debug, .maxlen = sizeof(int), .mode = 0644, |
6d4561110
|
146 |
.proc_handler = proc_dodebug |
cca5172a7
|
147 |
}, |
1da177e4c
|
148 |
{ |
1da177e4c
|
149 150 151 152 |
.procname = "nfsd_debug", .data = &nfsd_debug, .maxlen = sizeof(int), .mode = 0644, |
6d4561110
|
153 |
.proc_handler = proc_dodebug |
cca5172a7
|
154 |
}, |
1da177e4c
|
155 |
{ |
1da177e4c
|
156 157 158 159 |
.procname = "nlm_debug", .data = &nlm_debug, .maxlen = sizeof(int), .mode = 0644, |
6d4561110
|
160 |
.proc_handler = proc_dodebug |
cca5172a7
|
161 |
}, |
dc9a16e49
|
162 163 164 165 |
{ .procname = "transports", .maxlen = 256, .mode = 0444, |
6d4561110
|
166 |
.proc_handler = proc_do_xprt, |
dc9a16e49
|
167 |
}, |
f8572d8f2
|
168 |
{ } |
1da177e4c
|
169 |
}; |
fe2c6338f
|
170 |
static struct ctl_table sunrpc_table[] = { |
1da177e4c
|
171 |
{ |
1da177e4c
|
172 173 174 175 |
.procname = "sunrpc", .mode = 0555, .child = debug_table }, |
f8572d8f2
|
176 |
{ } |
1da177e4c
|
177 178 179 |
}; #endif |