hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/lib/test_sysctl.c
....@@ -16,7 +16,7 @@
1616 */
1717
1818 /*
19
- * This module provides an interface to the the proc sysctl interfaces. This
19
+ * This module provides an interface to the proc sysctl interfaces. This
2020 * driver requires CONFIG_PROC_SYSCTL. It will not normally be loaded by the
2121 * system unless explicitly requested by name. You can also build this driver
2222 * into your kernel.
....@@ -44,9 +44,14 @@
4444 int int_0002;
4545 int int_0003[4];
4646
47
+ int boot_int;
48
+
4749 unsigned int uint_0001;
4850
4951 char string_0001[65];
52
+
53
+#define SYSCTL_TEST_BITMAP_SIZE 65536
54
+ unsigned long *bitmap_0001;
5055 };
5156
5257 static struct test_sysctl_data test_data = {
....@@ -57,6 +62,8 @@
5762 .int_0003[1] = 1,
5863 .int_0003[2] = 2,
5964 .int_0003[3] = 3,
65
+
66
+ .boot_int = 0,
6067
6168 .uint_0001 = 314,
6269
....@@ -89,6 +96,15 @@
8996 .proc_handler = proc_dointvec,
9097 },
9198 {
99
+ .procname = "boot_int",
100
+ .data = &test_data.boot_int,
101
+ .maxlen = sizeof(test_data.boot_int),
102
+ .mode = 0644,
103
+ .proc_handler = proc_dointvec,
104
+ .extra1 = SYSCTL_ZERO,
105
+ .extra2 = SYSCTL_ONE,
106
+ },
107
+ {
92108 .procname = "uint_0001",
93109 .data = &test_data.uint_0001,
94110 .maxlen = sizeof(unsigned int),
....@@ -101,6 +117,13 @@
101117 .maxlen = sizeof(test_data.string_0001),
102118 .mode = 0644,
103119 .proc_handler = proc_dostring,
120
+ },
121
+ {
122
+ .procname = "bitmap_0001",
123
+ .data = &test_data.bitmap_0001,
124
+ .maxlen = SYSCTL_TEST_BITMAP_SIZE,
125
+ .mode = 0644,
126
+ .proc_handler = proc_do_large_bitmap,
104127 },
105128 { }
106129 };
....@@ -129,15 +152,21 @@
129152
130153 static int __init test_sysctl_init(void)
131154 {
132
- test_sysctl_header = register_sysctl_table(test_sysctl_root_table);
133
- if (!test_sysctl_header)
155
+ test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL);
156
+ if (!test_data.bitmap_0001)
134157 return -ENOMEM;
158
+ test_sysctl_header = register_sysctl_table(test_sysctl_root_table);
159
+ if (!test_sysctl_header) {
160
+ kfree(test_data.bitmap_0001);
161
+ return -ENOMEM;
162
+ }
135163 return 0;
136164 }
137
-late_initcall(test_sysctl_init);
165
+module_init(test_sysctl_init);
138166
139167 static void __exit test_sysctl_exit(void)
140168 {
169
+ kfree(test_data.bitmap_0001);
141170 if (test_sysctl_header)
142171 unregister_sysctl_table(test_sysctl_header);
143172 }