Whamcloud - gitweb
- Added DEBUG_SUBSYSTEMs
[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 #define DEBUG_SUBSYSTEM S_CLASS
25
26 #include <linux/obd_support.h>
27
28 struct ctl_table_header *obd_table_header = NULL;
29
30 static int vars[2];
31 static int index = 0;
32
33 static int obd_sctl_vars( ctl_table * table, int write, struct file *
34                           filp, void * buffer, size_t * lenp );
35 static int obd_sctl_reset( ctl_table * table, int write, struct file
36                            * filp, void * buffer, size_t * lenp );
37
38 #define OBD_SYSCTL 300
39
40 #define OBD_DEBUG           1       /* control debugging */
41 #define OBD_ENTRY           2       /* control enter/leave pattern */
42 #define OBD_TIMEOUT         3       /* timeout on upcalls to become intrble */
43 #define OBD_HARD            4       /* mount type "hard" or "soft" */
44 #define OBD_VARS            5       
45 #define OBD_INDEX           6
46 #define OBD_RESET           7
47
48 #define OBD_VARS_SLOT       2
49
50 static ctl_table obd_table[] = {
51         {OBD_DEBUG, "debug", &obd_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
52         {OBD_ENTRY, "trace", &obd_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
53         {OBD_VARS, "vars", &vars[0], sizeof(int), 0644, NULL, &proc_dointvec},
54         {OBD_INDEX, "index", &index, sizeof(int), 0644, NULL, &obd_sctl_vars},
55         {OBD_RESET, "reset", NULL, 0, 0644, NULL, &obd_sctl_reset},
56         { 0 }
57 };
58
59 static ctl_table parent_table[] = {
60        {OBD_SYSCTL, "obd",    NULL, 0, 0555, obd_table},
61        {0}
62 };
63
64 void obd_sysctl_init (void)
65 {
66 #ifdef CONFIG_SYSCTL
67         if ( !obd_table_header )
68                 obd_table_header = register_sysctl_table(parent_table, 0); 
69 #endif
70 }
71
72 void obd_sysctl_clean (void)
73 {
74 #ifdef CONFIG_SYSCTL
75         if ( obd_table_header )
76                 unregister_sysctl_table(obd_table_header);
77         obd_table_header = NULL;
78 #endif
79 }
80
81 int obd_sctl_reset (ctl_table * table, int write, 
82                     struct file * filp, void * buffer, 
83                     size_t * lenp)
84 {
85         if ( write ) {
86                 /* do something here */
87                 vars[0]=0;
88                 vars[1]=0;
89         }
90
91         *lenp = 0;
92         return 0;
93 }
94
95 int obd_sctl_vars (ctl_table * table, int write, 
96                    struct file * filp, void * buffer, 
97                    size_t * lenp)
98 {
99         int rc;
100
101         rc = proc_dointvec(table, write, filp, buffer, lenp);
102
103         if ( rc ) 
104                 return rc;
105
106         if ( index < 0 || index > 1 ) {
107                 printk(KERN_WARNING __FUNCTION__ "Illegal index %d!\n", index);
108                 index = 0;
109         } else {
110                 obd_table[OBD_VARS_SLOT].data = &vars[index];
111         }
112
113         return rc; 
114 }
115
116
117
118