OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [sunrpc/] [sysctl.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * linux/net/sunrpc/sysctl.c
3
 *
4
 * Sysctl interface to sunrpc module. This is for debugging only now.
5
 *
6
 * I would prefer to register the sunrpc table below sys/net, but that's
7
 * impossible at the moment.
8
 */
9
 
10
#include <linux/config.h>
11
#include <linux/version.h>
12
#include <linux/types.h>
13
#include <linux/linkage.h>
14
#include <linux/ctype.h>
15
#include <linux/fs.h>
16
#include <linux/sysctl.h>
17
#include <linux/module.h>
18
 
19
#include <asm/uaccess.h>
20
#include <linux/sunrpc/types.h>
21
#include <linux/sunrpc/sched.h>
22
#include <linux/sunrpc/stats.h>
23
 
24
/*
25
 * Declare the debug flags here
26
 */
27
unsigned int    rpc_debug;
28
unsigned int    nfs_debug;
29
unsigned int    nfsd_debug;
30
unsigned int    nlm_debug;
31
 
32
#ifdef RPC_DEBUG
33
 
34
static struct ctl_table_header *sunrpc_table_header;
35
static ctl_table                sunrpc_table[];
36
 
37
void
38
rpc_register_sysctl(void)
39
{
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
46
        }
47
 
48
}
49
 
50
void
51
rpc_unregister_sysctl(void)
52
{
53
        if (sunrpc_table_header) {
54
                unregister_sysctl_table(sunrpc_table_header);
55
                sunrpc_table_header = NULL;
56
        }
57
}
58
 
59
static int
60
proc_dodebug(ctl_table *table, int write, struct file *file,
61
                                void *buffer, size_t *lenp)
62
{
63
        char            tmpbuf[20], *p, c;
64
        unsigned int    value;
65
        size_t          left, len;
66
 
67
        if ((file->f_pos && !write) || !*lenp) {
68
                *lenp = 0;
69
                return 0;
70
        }
71
 
72
        left = *lenp;
73
 
74
        if (write) {
75
                if (!access_ok(VERIFY_READ, buffer, left))
76
                        return -EFAULT;
77
                p = (char *) buffer;
78
                while (left && __get_user(c, p) >= 0 && isspace(c))
79
                        left--, p++;
80
                if (!left)
81
                        goto done;
82
 
83
                if (left > sizeof(tmpbuf) - 1)
84
                        return -EINVAL;
85
                copy_from_user(tmpbuf, p, left);
86
                tmpbuf[left] = '\0';
87
 
88
                for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
89
                        value = 10 * value + (*p - '0');
90
                if (*p && !isspace(*p))
91
                        return -EINVAL;
92
                while (left && isspace(*p))
93
                        left--, p++;
94
                *(unsigned int *) table->data = value;
95
                /* Display the RPC tasks on writing to rpc_debug */
96
                if (table->ctl_name == CTL_RPCDEBUG) {
97
                        rpc_show_tasks();
98
                }
99
        } else {
100
                if (!access_ok(VERIFY_WRITE, buffer, left))
101
                        return -EFAULT;
102
                len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
103
                if (len > left)
104
                        len = left;
105
                copy_to_user(buffer, tmpbuf, len);
106
                if ((left -= len) > 0) {
107
                        put_user('\n', (char *)buffer + len);
108
                        left--;
109
                }
110
        }
111
 
112
done:
113
        *lenp -= left;
114
        file->f_pos += *lenp;
115
        return 0;
116
}
117
 
118
#define DIRENTRY(nam1, nam2, child)     \
119
        {CTL_##nam1, #nam2, NULL, 0, 0555, child }
120
#define DBGENTRY(nam1, nam2)    \
121
        {CTL_##nam1##DEBUG, #nam2 "_debug", &nam2##_debug, sizeof(int),\
122
         0644, NULL, &proc_dodebug}
123
 
124
static ctl_table                debug_table[] = {
125
        DBGENTRY(RPC,  rpc),
126
        DBGENTRY(NFS,  nfs),
127
        DBGENTRY(NFSD, nfsd),
128
        DBGENTRY(NLM,  nlm),
129
        {0}
130
};
131
 
132
static ctl_table                sunrpc_table[] = {
133
        DIRENTRY(SUNRPC, sunrpc, debug_table),
134
        {0}
135
};
136
 
137
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.