/*
|
/*
|
* linux/net/sunrpc/sysctl.c
|
* linux/net/sunrpc/sysctl.c
|
*
|
*
|
* Sysctl interface to sunrpc module. This is for debugging only now.
|
* Sysctl interface to sunrpc module. This is for debugging only now.
|
*
|
*
|
* I would prefer to register the sunrpc table below sys/net, but that's
|
* I would prefer to register the sunrpc table below sys/net, but that's
|
* impossible at the moment.
|
* impossible at the moment.
|
*/
|
*/
|
|
|
#include <linux/config.h>
|
#include <linux/config.h>
|
#include <linux/version.h>
|
#include <linux/version.h>
|
#include <linux/types.h>
|
#include <linux/types.h>
|
#include <linux/linkage.h>
|
#include <linux/linkage.h>
|
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
#include <linux/fs.h>
|
#include <linux/fs.h>
|
#include <linux/sysctl.h>
|
#include <linux/sysctl.h>
|
#include <linux/module.h>
|
#include <linux/module.h>
|
|
|
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
#include <linux/sunrpc/types.h>
|
#include <linux/sunrpc/types.h>
|
#include <linux/sunrpc/sched.h>
|
#include <linux/sunrpc/sched.h>
|
#include <linux/sunrpc/stats.h>
|
#include <linux/sunrpc/stats.h>
|
|
|
/*
|
/*
|
* Declare the debug flags here
|
* Declare the debug flags here
|
*/
|
*/
|
unsigned int rpc_debug;
|
unsigned int rpc_debug;
|
unsigned int nfs_debug;
|
unsigned int nfs_debug;
|
unsigned int nfsd_debug;
|
unsigned int nfsd_debug;
|
unsigned int nlm_debug;
|
unsigned int nlm_debug;
|
|
|
#ifdef RPC_DEBUG
|
#ifdef RPC_DEBUG
|
|
|
static struct ctl_table_header *sunrpc_table_header;
|
static struct ctl_table_header *sunrpc_table_header;
|
static ctl_table sunrpc_table[];
|
static ctl_table sunrpc_table[];
|
|
|
void
|
void
|
rpc_register_sysctl(void)
|
rpc_register_sysctl(void)
|
{
|
{
|
if (!sunrpc_table_header) {
|
if (!sunrpc_table_header) {
|
sunrpc_table_header = register_sysctl_table(sunrpc_table, 1);
|
sunrpc_table_header = register_sysctl_table(sunrpc_table, 1);
|
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
if (sunrpc_table[0].de)
|
if (sunrpc_table[0].de)
|
sunrpc_table[0].de->owner = THIS_MODULE;
|
sunrpc_table[0].de->owner = THIS_MODULE;
|
#endif
|
#endif
|
}
|
}
|
|
|
}
|
}
|
|
|
void
|
void
|
rpc_unregister_sysctl(void)
|
rpc_unregister_sysctl(void)
|
{
|
{
|
if (sunrpc_table_header) {
|
if (sunrpc_table_header) {
|
unregister_sysctl_table(sunrpc_table_header);
|
unregister_sysctl_table(sunrpc_table_header);
|
sunrpc_table_header = NULL;
|
sunrpc_table_header = NULL;
|
}
|
}
|
}
|
}
|
|
|
static int
|
static int
|
proc_dodebug(ctl_table *table, int write, struct file *file,
|
proc_dodebug(ctl_table *table, int write, struct file *file,
|
void *buffer, size_t *lenp)
|
void *buffer, size_t *lenp)
|
{
|
{
|
char tmpbuf[20], *p, c;
|
char tmpbuf[20], *p, c;
|
unsigned int value;
|
unsigned int value;
|
size_t left, len;
|
size_t left, len;
|
|
|
if ((file->f_pos && !write) || !*lenp) {
|
if ((file->f_pos && !write) || !*lenp) {
|
*lenp = 0;
|
*lenp = 0;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
left = *lenp;
|
left = *lenp;
|
|
|
if (write) {
|
if (write) {
|
if (!access_ok(VERIFY_READ, buffer, left))
|
if (!access_ok(VERIFY_READ, buffer, left))
|
return -EFAULT;
|
return -EFAULT;
|
p = (char *) buffer;
|
p = (char *) buffer;
|
while (left && __get_user(c, p) >= 0 && isspace(c))
|
while (left && __get_user(c, p) >= 0 && isspace(c))
|
left--, p++;
|
left--, p++;
|
if (!left)
|
if (!left)
|
goto done;
|
goto done;
|
|
|
if (left > sizeof(tmpbuf) - 1)
|
if (left > sizeof(tmpbuf) - 1)
|
return -EINVAL;
|
return -EINVAL;
|
copy_from_user(tmpbuf, p, left);
|
copy_from_user(tmpbuf, p, left);
|
tmpbuf[left] = '\0';
|
tmpbuf[left] = '\0';
|
|
|
for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
|
for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
|
value = 10 * value + (*p - '0');
|
value = 10 * value + (*p - '0');
|
if (*p && !isspace(*p))
|
if (*p && !isspace(*p))
|
return -EINVAL;
|
return -EINVAL;
|
while (left && isspace(*p))
|
while (left && isspace(*p))
|
left--, p++;
|
left--, p++;
|
*(unsigned int *) table->data = value;
|
*(unsigned int *) table->data = value;
|
/* Display the RPC tasks on writing to rpc_debug */
|
/* Display the RPC tasks on writing to rpc_debug */
|
if (table->ctl_name == CTL_RPCDEBUG) {
|
if (table->ctl_name == CTL_RPCDEBUG) {
|
rpc_show_tasks();
|
rpc_show_tasks();
|
}
|
}
|
} else {
|
} else {
|
if (!access_ok(VERIFY_WRITE, buffer, left))
|
if (!access_ok(VERIFY_WRITE, buffer, left))
|
return -EFAULT;
|
return -EFAULT;
|
len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
|
len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
|
if (len > left)
|
if (len > left)
|
len = left;
|
len = left;
|
copy_to_user(buffer, tmpbuf, len);
|
copy_to_user(buffer, tmpbuf, len);
|
if ((left -= len) > 0) {
|
if ((left -= len) > 0) {
|
put_user('\n', (char *)buffer + len);
|
put_user('\n', (char *)buffer + len);
|
left--;
|
left--;
|
}
|
}
|
}
|
}
|
|
|
done:
|
done:
|
*lenp -= left;
|
*lenp -= left;
|
file->f_pos += *lenp;
|
file->f_pos += *lenp;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
#define DIRENTRY(nam1, nam2, child) \
|
#define DIRENTRY(nam1, nam2, child) \
|
{CTL_##nam1, #nam2, NULL, 0, 0555, child }
|
{CTL_##nam1, #nam2, NULL, 0, 0555, child }
|
#define DBGENTRY(nam1, nam2) \
|
#define DBGENTRY(nam1, nam2) \
|
{CTL_##nam1##DEBUG, #nam2 "_debug", &nam2##_debug, sizeof(int),\
|
{CTL_##nam1##DEBUG, #nam2 "_debug", &nam2##_debug, sizeof(int),\
|
0644, NULL, &proc_dodebug}
|
0644, NULL, &proc_dodebug}
|
|
|
static ctl_table debug_table[] = {
|
static ctl_table debug_table[] = {
|
DBGENTRY(RPC, rpc),
|
DBGENTRY(RPC, rpc),
|
DBGENTRY(NFS, nfs),
|
DBGENTRY(NFS, nfs),
|
DBGENTRY(NFSD, nfsd),
|
DBGENTRY(NFSD, nfsd),
|
DBGENTRY(NLM, nlm),
|
DBGENTRY(NLM, nlm),
|
{0}
|
{0}
|
};
|
};
|
|
|
static ctl_table sunrpc_table[] = {
|
static ctl_table sunrpc_table[] = {
|
DIRENTRY(SUNRPC, sunrpc, debug_table),
|
DIRENTRY(SUNRPC, sunrpc, debug_table),
|
{0}
|
{0}
|
};
|
};
|
|
|
#endif
|
#endif
|
|
|