Added module parameters to the hello modlue
PATCH 1/1 Added module parameters to the hello modlue
I’ve followed these steps to add module parameters and capture the dmesg output:
I included the module.h header and used the module_param() macro to take the argument value as input from the command line. At runtime, insmod will take the input for the "name" variable. The default value is "World" if no input is provided.
Dmesg Output:
[27901.755598] Removing module... Goodbye World! [27978.985148] Loading module... Hello Sumya
Signed-off-by Sumya Hoque <[email protected]>
--- linux_custom_modules/hello.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
linux_custom_modules/hello.c +4 -1
@@ -1,8 +1,11 @@#include <linux/module.h> #include <linux/printk.h> +#include <linux/kernel.h> +char *name ="World" ; +module_param (name, charp,0000 );int hello (void ) { -printk (KERN_INFO "Loading module... Hello World!\n" ); +printk (KERN_INFO "Loading module... Hello %s\n" , name);return 0 ; }
Signature · 1 line
2.34.1