Whamcloud - gitweb
Update copyright and license information.
[fs/lustre-release.git] / lustre / obdclass / sysctl.c
1 /*
2  * Copyright (C) 2001  Cluster File Systems, Inc.
3  *
4  * This code is issued under the GNU General Public License.
5  * See the file COPYING in this distribution
6  */
7
8 #include <linux/module.h>
9 #include <linux/autoconf.h>
10 #include <linux/sysctl.h>
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <linux/sysctl.h>
14 #include <linux/swapctl.h>
15 #include <linux/proc_fs.h>
16 #include <linux/slab.h>
17 #include <linux/stat.h>
18 #include <linux/ctype.h>
19 #include <asm/bitops.h>
20 #include <asm/segment.h>
21 #include <asm/uaccess.h>
22 #include <linux/utsname.h>
23
24 #include <linux/obd_support.h>
25
26 struct ctl_table_header *obd_table_header = NULL;
27
28 static int vars[2];
29 static int index = 0;
30
31 static int obd_sctl_vars( ctl_table * table, int write, struct file *
32                           filp, void * buffer, size_t * lenp );
33 static int obd_sctl_reset( ctl_table * table, int write, struct file
34                            * filp, void * buffer, size_t * lenp );
35
36 #define OBD_SYSCTL 300
37
38 #define OBD_DEBUG           1       /* control debugging */
39 #define OBD_ENTRY           2       /* control enter/leave pattern */
40 #define OBD_TIMEOUT         3       /* timeout on upcalls to become intrble */
41 #define OBD_HARD            4       /* mount type "hard" or "soft" */
42 #define OBD_VARS            5       
43 #define OBD_INDEX           6
44 #define OBD_RESET           7
45
46 #define OBD_VARS_SLOT       2
47
48 static ctl_table obd_table[] = {
49         {OBD_DEBUG, "debug", &obd_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
50         {OBD_ENTRY, "trace", &obd_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
51         {OBD_VARS, "vars", &vars[0], sizeof(int), 0644, NULL, &proc_dointvec},
52         {OBD_INDEX, "index", &index, sizeof(int), 0644, NULL, &obd_sctl_vars},
53         {OBD_RESET, "reset", NULL, 0, 0644, NULL, &obd_sctl_reset},
54         { 0 }
55 };
56
57 static ctl_table parent_table[] = {
58        {OBD_SYSCTL, "obd",    NULL, 0, 0555, obd_table},
59        {0}
60 };
61
62 void obd_sysctl_init (void)
63 {
64 #ifdef CONFIG_SYSCTL
65         if ( !obd_table_header )
66                 obd_table_header = register_sysctl_table(parent_table, 0); 
67 #endif
68 }
69
70 void obd_sysctl_clean (void)
71 {
72 #ifdef CONFIG_SYSCTL
73         if ( obd_table_header )
74                 unregister_sysctl_table(obd_table_header);
75         obd_table_header = NULL;
76 #endif
77 }
78
79 int obd_sctl_reset (ctl_table * table, int write, 
80                     struct file * filp, void * buffer, 
81                     size_t * lenp)
82 {
83         if ( write ) {
84                 /* do something here */
85                 vars[0]=0;
86                 vars[1]=0;
87         }
88
89         *lenp = 0;
90         return 0;
91 }
92
93 int obd_sctl_vars (ctl_table * table, int write, 
94                    struct file * filp, void * buffer, 
95                    size_t * lenp)
96 {
97         int rc;
98
99         rc = proc_dointvec(table, write, filp, buffer, lenp);
100
101         if ( rc ) 
102                 return rc;
103
104         if ( index < 0 || index > 1 ) {
105                 printk(KERN_WARNING __FUNCTION__ "Illegal index %d!\n", index);
106                 index = 0;
107         } else {
108                 obd_table[OBD_VARS_SLOT].data = &vars[index];
109         }
110
111         return rc; 
112 }
113
114
115
116