Linux 4.13: use designated initializers where required
[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 HAVE_LINUX_CONFIG_H
18 #include <linux/config.h>
19 #endif
20
21 /* From afs_util.c */
22 extern afs_int32 afs_md5inum;
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 struct ctl_table afs_sysctl_table[] = {
38     {
39 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
40 #if defined(CTL_UNNUMBERED)
41         .ctl_name       = CTL_UNNUMBERED, 
42 #else
43         .ctl_name       = 1, 
44 #endif
45 #endif
46         .procname       = "hm_retry_RO",
47         .data           = &hm_retry_RO, 
48         .maxlen         = sizeof(afs_int32), 
49         .mode           = 0644,
50         .proc_handler   = &proc_dointvec
51     },
52     {
53 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
54 #if defined(CTL_UNNUMBERED)
55         .ctl_name       = CTL_UNNUMBERED, 
56 #else
57         .ctl_name       = 2, 
58 #endif
59 #endif
60         .procname       = "hm_retry_RW",
61         .data           = &hm_retry_RW,
62         .maxlen         = sizeof(afs_int32), 
63         .mode           = 0644,
64         .proc_handler   = &proc_dointvec
65     },
66     {
67 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
68 #if defined(CTL_UNNUMBERED)
69         .ctl_name       = CTL_UNNUMBERED, 
70 #else
71         .ctl_name       = 3, 
72 #endif
73 #endif
74         .procname       = "hm_retry_int",
75         .data           = &hm_retry_int, 
76         .maxlen         = sizeof(afs_int32), 
77         .mode           = 0644,
78         .proc_handler   = &proc_dointvec
79     },
80     {
81 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
82 #if defined(CTL_UNNUMBERED)
83         .ctl_name       = CTL_UNNUMBERED, 
84 #else
85         .ctl_name       = 4, 
86 #endif
87 #endif
88         .procname       = "GCPAGs",
89         .data           = &afs_gcpags, 
90         .maxlen         = sizeof(afs_int32), 
91         .mode           = 0644,
92         .proc_handler   = &proc_dointvec
93     },
94     {
95 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
96 #if defined(CTL_UNNUMBERED)
97         .ctl_name       = CTL_UNNUMBERED, 
98 #else
99         .ctl_name       = 5, 
100 #endif
101 #endif
102         .procname       = "rx_deadtime",
103         .data           = &afs_rx_deadtime, 
104         .maxlen         = sizeof(afs_int32), 
105         .mode           = 0644,
106         .proc_handler   = &proc_dointvec
107     },
108     {
109 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
110 #if defined(CTL_UNNUMBERED)
111         .ctl_name       = CTL_UNNUMBERED, 
112 #else
113         .ctl_name       = 6, 
114 #endif
115 #endif
116         .procname       = "bkVolPref",
117         .data           = &afs_bkvolpref, 
118         .maxlen         = sizeof(afs_int32), 
119         .mode           = 0644,
120         .proc_handler   = &proc_dointvec
121     },
122     {
123 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
124 #if defined(CTL_UNNUMBERED)
125         .ctl_name       = CTL_UNNUMBERED, 
126 #else
127         .ctl_name       = 7, 
128 #endif
129 #endif
130         .procname       = "afs_blocksUsed",
131         .data           = &afs_blocksUsed,
132         .maxlen         = sizeof(afs_int32), 
133         .mode           = 0444,
134         .proc_handler   = &proc_dointvec
135     },
136     {
137 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
138 #if defined(CTL_UNNUMBERED)
139         .ctl_name       = CTL_UNNUMBERED, 
140 #else
141         .ctl_name       = 8, 
142 #endif
143 #endif
144         .procname       = "afs_blocksUsed_0",
145         .data           = &afs_blocksUsed_0,
146         .maxlen         = sizeof(afs_int32),
147         .mode           = 0644,
148         .proc_handler   = &proc_dointvec
149     },
150     {
151 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
152 #if defined(CTL_UNNUMBERED)
153         .ctl_name       = CTL_UNNUMBERED, 
154 #else
155         .ctl_name       = 9, 
156 #endif
157 #endif
158         .procname       = "afs_blocksUsed_1",
159         .data           = &afs_blocksUsed_1, 
160         .maxlen         = sizeof(afs_int32),
161         .mode           = 0644,
162         .proc_handler   = &proc_dointvec
163     },
164     {
165 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
166 #if defined(CTL_UNNUMBERED)
167         .ctl_name       = CTL_UNNUMBERED, 
168 #else
169         .ctl_name       = 10, 
170 #endif
171 #endif
172         .procname       = "afs_blocksUsed_2",
173         .data           = &afs_blocksUsed_2, 
174         .maxlen         = sizeof(afs_int32), 
175         .mode           = 0644,
176         .proc_handler   = &proc_dointvec
177     },
178     {
179 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
180 #if defined(CTL_UNNUMBERED)
181         .ctl_name       = CTL_UNNUMBERED, 
182 #else
183         .ctl_name       = 11, 
184 #endif
185 #endif
186         .procname       = "afs_pct1",
187         .data           = &afs_pct1, 
188         .maxlen         = sizeof(afs_int32),
189         .mode           = 0644,
190         .proc_handler   = &proc_dointvec
191     },
192     {
193 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
194 #if defined(CTL_UNNUMBERED)
195         .ctl_name       = CTL_UNNUMBERED, 
196 #else
197         .ctl_name       = 12, 
198 #endif
199 #endif
200         .procname       = "afs_pct2",
201         .data           = &afs_pct2, 
202         .maxlen         = sizeof(afs_int32),
203         .mode           = 0644,
204         .proc_handler   = &proc_dointvec
205     },
206     {
207 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
208 #if defined(CTL_UNNUMBERED)
209         .ctl_name       = CTL_UNNUMBERED, 
210 #else
211         .ctl_name       = 13,
212 #endif
213 #endif
214         .procname       = "afs_cacheBlocks",
215         .data           = &afs_cacheBlocks,
216         .maxlen         = sizeof(afs_int32),
217         .mode           = 0644,
218         .proc_handler   = &proc_dointvec
219     },
220     {
221 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
222 #if defined(CTL_UNNUMBERED)
223         .ctl_name       = CTL_UNNUMBERED, 
224 #else
225         .ctl_name       = 14, 
226 #endif
227 #endif
228         .procname       = "md5inum",
229         .data           = &afs_md5inum,
230         .maxlen         = sizeof(afs_int32),
231         .mode           = 0644,
232         .proc_handler   = &proc_dointvec
233     },
234     {
235         .procname       = 0
236     }
237 };
238
239 static struct ctl_table fs_sysctl_table[] = {
240     {
241 #if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
242 #if defined(CTL_UNNUMBERED)
243         .ctl_name       = CTL_UNNUMBERED, 
244 #else
245         .ctl_name       = 1, 
246 #endif
247 #endif
248         .procname       = "afs", 
249         .mode           = 0555, 
250         .child          = afs_sysctl_table
251     },
252     {
253         .procname       = 0
254     }
255 };
256
257 int
258 osi_sysctl_init()
259 {
260 #if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
261     afs_sysctl = register_sysctl_table(fs_sysctl_table);
262 #else
263     afs_sysctl = register_sysctl_table(fs_sysctl_table, 0);
264 #endif
265     if (!afs_sysctl)
266         return -1;
267
268     return 0;
269 }
270
271 void
272 osi_sysctl_clean()
273 {
274     if (afs_sysctl) {
275         unregister_sysctl_table(afs_sysctl);
276         afs_sysctl = NULL;
277     }
278 }
279
280 #endif /* CONFIG_SYSCTL */