| .. | .. |
|---|
| 16 | 16 | */ |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | /* |
|---|
| 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 |
|---|
| 20 | 20 | * driver requires CONFIG_PROC_SYSCTL. It will not normally be loaded by the |
|---|
| 21 | 21 | * system unless explicitly requested by name. You can also build this driver |
|---|
| 22 | 22 | * into your kernel. |
|---|
| .. | .. |
|---|
| 44 | 44 | int int_0002; |
|---|
| 45 | 45 | int int_0003[4]; |
|---|
| 46 | 46 | |
|---|
| 47 | + int boot_int; |
|---|
| 48 | + |
|---|
| 47 | 49 | unsigned int uint_0001; |
|---|
| 48 | 50 | |
|---|
| 49 | 51 | char string_0001[65]; |
|---|
| 52 | + |
|---|
| 53 | +#define SYSCTL_TEST_BITMAP_SIZE 65536 |
|---|
| 54 | + unsigned long *bitmap_0001; |
|---|
| 50 | 55 | }; |
|---|
| 51 | 56 | |
|---|
| 52 | 57 | static struct test_sysctl_data test_data = { |
|---|
| .. | .. |
|---|
| 57 | 62 | .int_0003[1] = 1, |
|---|
| 58 | 63 | .int_0003[2] = 2, |
|---|
| 59 | 64 | .int_0003[3] = 3, |
|---|
| 65 | + |
|---|
| 66 | + .boot_int = 0, |
|---|
| 60 | 67 | |
|---|
| 61 | 68 | .uint_0001 = 314, |
|---|
| 62 | 69 | |
|---|
| .. | .. |
|---|
| 89 | 96 | .proc_handler = proc_dointvec, |
|---|
| 90 | 97 | }, |
|---|
| 91 | 98 | { |
|---|
| 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 | + { |
|---|
| 92 | 108 | .procname = "uint_0001", |
|---|
| 93 | 109 | .data = &test_data.uint_0001, |
|---|
| 94 | 110 | .maxlen = sizeof(unsigned int), |
|---|
| .. | .. |
|---|
| 101 | 117 | .maxlen = sizeof(test_data.string_0001), |
|---|
| 102 | 118 | .mode = 0644, |
|---|
| 103 | 119 | .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, |
|---|
| 104 | 127 | }, |
|---|
| 105 | 128 | { } |
|---|
| 106 | 129 | }; |
|---|
| .. | .. |
|---|
| 129 | 152 | |
|---|
| 130 | 153 | static int __init test_sysctl_init(void) |
|---|
| 131 | 154 | { |
|---|
| 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) |
|---|
| 134 | 157 | 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 | + } |
|---|
| 135 | 163 | return 0; |
|---|
| 136 | 164 | } |
|---|
| 137 | | -late_initcall(test_sysctl_init); |
|---|
| 165 | +module_init(test_sysctl_init); |
|---|
| 138 | 166 | |
|---|
| 139 | 167 | static void __exit test_sysctl_exit(void) |
|---|
| 140 | 168 | { |
|---|
| 169 | + kfree(test_data.bitmap_0001); |
|---|
| 141 | 170 | if (test_sysctl_header) |
|---|
| 142 | 171 | unregister_sysctl_table(test_sysctl_header); |
|---|
| 143 | 172 | } |
|---|