9abaeeb3abafed8850ca14cfb5c313ac2bad64d3
[openafs.git] / src / afs / LINUX / osi_sysctl.c
1 /*
2  * osi_sysctl.c: Linux sysctl interface to OpenAFS
3  *
4  * $Id$
5  *
6  * Written Jan 30, 2002 by Kris Van Hees (Sine Nomine Associates)
7  */
8
9 #include <afsconfig.h>
10 #include "afs/param.h"
11
12 #include "afs/sysincludes.h"    /* Standard vendor system headers */
13 #include "afsincludes.h"        /* Afs-based standard headers */
14 #include "afs/afs_stats.h"      /* afs statistics */
15
16 #include <linux/sysctl.h>
17 #ifdef CONFIG_H_EXISTS
18 #include <linux/config.h>
19 #endif
20
21 /* From afs_util.c */
22 extern afs_int32 afs_new_inum;
23
24 /* From afs_analyze.c */
25 extern afs_int32 hm_retry_RO;
26 extern afs_int32 hm_retry_RW;
27 extern afs_int32 hm_retry_int;
28 extern afs_int32 afs_blocksUsed_0;
29 extern afs_int32 afs_blocksUsed_1;
30 extern afs_int32 afs_blocksUsed_2;
31 extern afs_int32 afs_pct1;
32 extern afs_int32 afs_pct2;
33
34 #ifdef CONFIG_SYSCTL
35 static struct ctl_table_header *afs_sysctl = NULL;
36
37 static ctl_table afs_sysctl_table[] = {
38     {1, "hm_retry_RO",
39      &hm_retry_RO, sizeof(afs_int32), 0644, NULL,
40      &proc_dointvec}
41     ,
42     {2, "hm_retry_RW",
43      &hm_retry_RW, sizeof(afs_int32), 0644, NULL,
44      &proc_dointvec}
45     ,
46     {3, "hm_retry_int",
47      &hm_retry_int, sizeof(afs_int32), 0644, NULL,
48      &proc_dointvec}
49     ,
50     {4, "GCPAGs",
51      &afs_gcpags, sizeof(afs_int32), 0644, NULL,
52      &proc_dointvec}
53     ,
54     {5, "rx_deadtime",
55      &afs_rx_deadtime, sizeof(afs_int32), 0644, NULL,
56      &proc_dointvec}
57     ,
58     {6, "bkVolPref",
59      &afs_bkvolpref, sizeof(afs_int32), 0644, NULL,
60      &proc_dointvec}
61     ,
62     {7, "afs_blocksUsed",
63      &afs_blocksUsed, sizeof(afs_int32), 0444, NULL,
64      &proc_dointvec}
65     ,
66     {8, "afs_blocksUsed_0",
67      &afs_blocksUsed_0, sizeof(afs_int32), 0644, NULL,
68      &proc_dointvec}
69     ,
70     {9, "afs_blocksUsed_1",
71      &afs_blocksUsed_1, sizeof(afs_int32), 0644, NULL,
72      &proc_dointvec}
73     ,
74     {10, "afs_blocksUsed_2",
75      &afs_blocksUsed_2, sizeof(afs_int32), 0644, NULL,
76      &proc_dointvec}
77     ,
78     {11, "afs_pct1",
79      &afs_pct1, sizeof(afs_int32), 0644, NULL,
80      &proc_dointvec}
81     ,
82     {12, "afs_pct2",
83      &afs_pct2, sizeof(afs_int32), 0644, NULL,
84      &proc_dointvec}
85     ,
86     {13, "afs_cacheBlocks",
87      &afs_cacheBlocks, sizeof(afs_int32), 0644, NULL,
88      &proc_dointvec}
89     ,
90     {7, "md5inum",
91      &afs_new_inum, sizeof(afs_int32), 0644, NULL,
92      &proc_dointvec}
93     ,
94     {0}
95 };
96
97 static ctl_table fs_sysctl_table[] = {
98     {1, "afs", NULL, 0, 0555, afs_sysctl_table},
99     {0}
100 };
101
102 int
103 osi_sysctl_init()
104 {
105 #if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
106     afs_sysctl = register_sysctl_table(fs_sysctl_table);
107 #else
108     afs_sysctl = register_sysctl_table(fs_sysctl_table, 0);
109 #endif
110     if (!afs_sysctl)
111         return -1;
112
113     return 0;
114 }
115
116 void
117 osi_sysctl_clean()
118 {
119     if (afs_sysctl) {
120         unregister_sysctl_table(afs_sysctl);
121         afs_sysctl = NULL;
122     }
123 }
124
125 #endif /* CONFIG_SYSCTL */