在/proc/sys/目录下创建文件
实现参数变更
#include <linux/module.h>
static struct ctl_table_header *ctl_table_test_header;
unsigned int sysctl_test_int;
char sysctl_test_string[256];
static struct ctl_table ctl_table_test[] = {
{
.procname = "test_int",
.data = &sysctl_test_int,
.maxlen = sizeof(unsigned int),
.mode = 0777,
.proc_handler = proc_dointvec,
},
{
.procname = "test_string",
.data = sysctl_test_string,
.maxlen = 255,
.mode = 0777,
.proc_handler = proc_dostring,
},
{}
};
static struct ctl_table ctl_table_test_root[] = {
{
.procname = "test_root",
.mode = 0555,
.child = ctl_table_test,
},
{}
};
static int __init test_init(void)
{
ctl_table_test_header = register_sysctl_table(ctl_table_test_root);
if (!ctl_table_test_header) {
printk("ctl_table_test_header error\n");
}
re