From 7f9807ce45c8260880d8887029ad2df427dfd5ff Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Mon, 5 Jun 2017 15:03:25 +0100 Subject: [PATCH] Multiple kernel params, busybox modinfo --- busybox_config_fragment | 1 + kernel_module/params.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/busybox_config_fragment b/busybox_config_fragment index d91c5a8..9a827c9 100644 --- a/busybox_config_fragment +++ b/busybox_config_fragment @@ -1,3 +1,4 @@ +CONFIG_MODINFO=y CONFIG_NC=y CONFIG_NC_EXTRA=y CONFIG_NC_SERVER=y diff --git a/kernel_module/params.c b/kernel_module/params.c index 90913cf..7738c80 100644 --- a/kernel_module/params.c +++ b/kernel_module/params.c @@ -4,15 +4,21 @@ Allows passing parameters at insertion time. Those parameters can also be read and modified at runtime from /sys. insmod /params.ko - # dmesg => 0 + # dmesg => 0 0 cd /sys/module/params/parameters cat i - # => 0 + # => 1 0 printf 1 >i - # dmesg => 1 + # dmesg => 1 0 rmmod params - insmod /params.ko i=1 - # dmesg => 1 + + insmod /params.ko i=1 j=1 + # dmesg => 1 1 + rmmod params + + modinfo + /params.ko + # Output contains MODULE_PARAM_DESC descriptions. */ #include /* usleep_range */ @@ -24,15 +30,18 @@ Those parameters can also be read and modified at runtime from /sys. MODULE_LICENSE("GPL"); static int i = 0; +static int j = 0; module_param(i, int, S_IRUSR | S_IWUSR); +module_param(j, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(i, "my favorite int"); +MODULE_PARM_DESC(j, "my second favorite int"); static struct task_struct *kthread; static int work_func(void *data) { while (!kthread_should_stop()) { - pr_info("%d\n", i); + pr_info("%d %d\n", i, j); usleep_range(1000000, 1000001); } return 0;