test_sysctl.c (2f56f84511367ce5ffd4a1c88dcd770ef049ea96) | test_sysctl.c (4f2f682d89d83fb6194562321d875253282d8496) |
---|---|
1/* 2 * proc sysctl test driver 3 * 4 * Copyright (C) 2017 Luis R. Rodriguez <mcgrof@kernel.org> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the Free 8 * Software Foundation; either version 2 of the License, or at your option any --- 30 unchanged lines hidden (view full) --- 39static int i_zero; 40static int i_one_hundred = 100; 41 42struct test_sysctl_data { 43 int int_0001; 44 int int_0002; 45 int int_0003[4]; 46 | 1/* 2 * proc sysctl test driver 3 * 4 * Copyright (C) 2017 Luis R. Rodriguez <mcgrof@kernel.org> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the Free 8 * Software Foundation; either version 2 of the License, or at your option any --- 30 unchanged lines hidden (view full) --- 39static int i_zero; 40static int i_one_hundred = 100; 41 42struct test_sysctl_data { 43 int int_0001; 44 int int_0002; 45 int int_0003[4]; 46 |
47 int boot_int; 48 |
|
47 unsigned int uint_0001; 48 49 char string_0001[65]; 50 51#define SYSCTL_TEST_BITMAP_SIZE 65536 52 unsigned long *bitmap_0001; 53}; 54 55static struct test_sysctl_data test_data = { 56 .int_0001 = 60, 57 .int_0002 = 1, 58 59 .int_0003[0] = 0, 60 .int_0003[1] = 1, 61 .int_0003[2] = 2, 62 .int_0003[3] = 3, 63 | 49 unsigned int uint_0001; 50 51 char string_0001[65]; 52 53#define SYSCTL_TEST_BITMAP_SIZE 65536 54 unsigned long *bitmap_0001; 55}; 56 57static struct test_sysctl_data test_data = { 58 .int_0001 = 60, 59 .int_0002 = 1, 60 61 .int_0003[0] = 0, 62 .int_0003[1] = 1, 63 .int_0003[2] = 2, 64 .int_0003[3] = 3, 65 |
66 .boot_int = 0, 67 |
|
64 .uint_0001 = 314, 65 66 .string_0001 = "(none)", 67}; 68 69/* These are all under /proc/sys/debug/test_sysctl/ */ 70static struct ctl_table test_table[] = { 71 { --- 15 unchanged lines hidden (view full) --- 87 { 88 .procname = "int_0003", 89 .data = &test_data.int_0003, 90 .maxlen = sizeof(test_data.int_0003), 91 .mode = 0644, 92 .proc_handler = proc_dointvec, 93 }, 94 { | 68 .uint_0001 = 314, 69 70 .string_0001 = "(none)", 71}; 72 73/* These are all under /proc/sys/debug/test_sysctl/ */ 74static struct ctl_table test_table[] = { 75 { --- 15 unchanged lines hidden (view full) --- 91 { 92 .procname = "int_0003", 93 .data = &test_data.int_0003, 94 .maxlen = sizeof(test_data.int_0003), 95 .mode = 0644, 96 .proc_handler = proc_dointvec, 97 }, 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 { |
|
95 .procname = "uint_0001", 96 .data = &test_data.uint_0001, 97 .maxlen = sizeof(unsigned int), 98 .mode = 0644, 99 .proc_handler = proc_douintvec, 100 }, 101 { 102 .procname = "string_0001", --- 41 unchanged lines hidden (view full) --- 144 return -ENOMEM; 145 test_sysctl_header = register_sysctl_table(test_sysctl_root_table); 146 if (!test_sysctl_header) { 147 kfree(test_data.bitmap_0001); 148 return -ENOMEM; 149 } 150 return 0; 151} | 108 .procname = "uint_0001", 109 .data = &test_data.uint_0001, 110 .maxlen = sizeof(unsigned int), 111 .mode = 0644, 112 .proc_handler = proc_douintvec, 113 }, 114 { 115 .procname = "string_0001", --- 41 unchanged lines hidden (view full) --- 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 } 163 return 0; 164} |
152module_init(test_sysctl_init); | 165late_initcall(test_sysctl_init); |
153 154static void __exit test_sysctl_exit(void) 155{ 156 kfree(test_data.bitmap_0001); 157 if (test_sysctl_header) 158 unregister_sysctl_table(test_sysctl_header); 159} 160 161module_exit(test_sysctl_exit); 162 163MODULE_AUTHOR("Luis R. Rodriguez <mcgrof@kernel.org>"); 164MODULE_LICENSE("GPL"); | 166 167static void __exit test_sysctl_exit(void) 168{ 169 kfree(test_data.bitmap_0001); 170 if (test_sysctl_header) 171 unregister_sysctl_table(test_sysctl_header); 172} 173 174module_exit(test_sysctl_exit); 175 176MODULE_AUTHOR("Luis R. Rodriguez <mcgrof@kernel.org>"); 177MODULE_LICENSE("GPL"); |