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