Blame view

net/sunrpc/sysctl.c 3.52 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
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   Linus Torvalds   Linux-2.6.12-rc2
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   Tom Tucker   svc: Add /proc/sy...
20
  #include <linux/sunrpc/svc_xprt.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
23
24
25
  
  /*
   * Declare the debug flags here
   */
  unsigned int	rpc_debug;
e8914c65f   Trond Myklebust   SUNRPC: Restrict ...
26
  EXPORT_SYMBOL_GPL(rpc_debug);
a6eaf8bdf   Trond Myklebust   SUNRPC: Move expo...
27

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
  unsigned int	nfs_debug;
e8914c65f   Trond Myklebust   SUNRPC: Restrict ...
29
  EXPORT_SYMBOL_GPL(nfs_debug);
a6eaf8bdf   Trond Myklebust   SUNRPC: Move expo...
30

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
  unsigned int	nfsd_debug;
e8914c65f   Trond Myklebust   SUNRPC: Restrict ...
32
  EXPORT_SYMBOL_GPL(nfsd_debug);
a6eaf8bdf   Trond Myklebust   SUNRPC: Move expo...
33

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
  unsigned int	nlm_debug;
e8914c65f   Trond Myklebust   SUNRPC: Restrict ...
35
  EXPORT_SYMBOL_GPL(nlm_debug);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
38
39
40
41
42
43
44
  
  #ifdef RPC_DEBUG
  
  static struct ctl_table_header *sunrpc_table_header;
  static ctl_table		sunrpc_table[];
  
  void
  rpc_register_sysctl(void)
  {
2b1bec5f5   Eric W. Biederman   [PATCH] sysctl: s...
45
  	if (!sunrpc_table_header)
0b4d41471   Eric W. Biederman   [PATCH] sysctl: r...
46
  		sunrpc_table_header = register_sysctl_table(sunrpc_table);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
49
50
51
52
53
54
55
56
  }
  
  void
  rpc_unregister_sysctl(void)
  {
  	if (sunrpc_table_header) {
  		unregister_sysctl_table(sunrpc_table_header);
  		sunrpc_table_header = NULL;
  	}
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
57
  static int proc_do_xprt(ctl_table *table, int write,
dc9a16e49   Tom Tucker   svc: Add /proc/sy...
58
59
60
  			void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	char tmpbuf[256];
27df6f25f   Cyrill Gorcunov   sunrpc: fix possi...
61
  	size_t len;
dc9a16e49   Tom Tucker   svc: Add /proc/sy...
62
63
64
65
  	if ((*ppos && !write) || !*lenp) {
  		*lenp = 0;
  		return 0;
  	}
27df6f25f   Cyrill Gorcunov   sunrpc: fix possi...
66
67
  	len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
  	return simple_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
dc9a16e49   Tom Tucker   svc: Add /proc/sy...
68
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
  static int
8d65af789   Alexey Dobriyan   sysctl: remove "s...
70
  proc_dodebug(ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
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
  				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   J. Bruce Fields   sunrpc: fix rpc d...
108
  		if (strcmp(table->procname, "rpc_debug") == 0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
109
  			rpc_show_tasks();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  	} 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   Chuck Lever   [PATCH] RPC: intr...
131

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
133
  static ctl_table debug_table[] = {
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
135
136
137
  		.procname	= "rpc_debug",
  		.data		= &rpc_debug,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
138
  		.proc_handler	= proc_dodebug
cca5172a7   YOSHIFUJI Hideaki   [NET] SUNRPC: Fix...
139
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
142
143
144
  		.procname	= "nfs_debug",
  		.data		= &nfs_debug,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
145
  		.proc_handler	= proc_dodebug
cca5172a7   YOSHIFUJI Hideaki   [NET] SUNRPC: Fix...
146
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148
149
150
151
  		.procname	= "nfsd_debug",
  		.data		= &nfsd_debug,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
152
  		.proc_handler	= proc_dodebug
cca5172a7   YOSHIFUJI Hideaki   [NET] SUNRPC: Fix...
153
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
156
157
158
  		.procname	= "nlm_debug",
  		.data		= &nlm_debug,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
159
  		.proc_handler	= proc_dodebug
cca5172a7   YOSHIFUJI Hideaki   [NET] SUNRPC: Fix...
160
  	},
dc9a16e49   Tom Tucker   svc: Add /proc/sy...
161
162
163
164
  	{
  		.procname	= "transports",
  		.maxlen		= 256,
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
165
  		.proc_handler	= proc_do_xprt,
dc9a16e49   Tom Tucker   svc: Add /proc/sy...
166
  	},
f8572d8f2   Eric W. Biederman   sysctl net: Remov...
167
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168
169
170
171
  };
  
  static ctl_table sunrpc_table[] = {
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
172
173
174
175
  		.procname	= "sunrpc",
  		.mode		= 0555,
  		.child		= debug_table
  	},
f8572d8f2   Eric W. Biederman   sysctl net: Remov...
176
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
177
178
179
  };
  
  #endif