{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Passing Arguments to Modules

Passing Arguments to Modules - Passing Arguments to Modules...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Passing Arguments to Modules Arguments can be passed to a loadable module at the time of loading. For example: sudo insmod ./second-mod.ko intParam=7 strParam="Hello” To get the parameters. Define the variables as follows: static int intParam = 5; static char *strParam = "DefaultStr"; module_param(intParam, int, 0000); MODULE_PARM_DESC(intParam, "parameter int"); module_param(strParam, charp, 0000); MODULE_PARM_DESC(strParam, "parameter str");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Passing Arguments to Modules // Module source file ‘second-mod.c'. #include <linux/module.h> // for all modules #include <linux/init.h> // for entry/exit macros #include <linux/kernel.h> // for printk priority macros #include <asm/current.h> // process information #include <linux/sched.h> // for "struct task_struct" static int intParam = 5; static char *strParam = "DefaultStr"; /* * module_param(foo, int, 0000) * The first param is the parameters name * The second param is it's data type * The final argument is the permissions bits,
Background image of page 2
Passing Arguments to Modules static int start_module(void) { printk("Second module is being loaded\n");
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}