Multiple kernel params, busybox modinfo

This commit is contained in:
Ciro Santilli
2017-06-05 15:03:25 +01:00
parent 709d01e513
commit 7f9807ce45
2 changed files with 16 additions and 6 deletions

View File

@@ -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 <linux/delay.h> /* 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;