I am trying to make my module printk displayable. I am new to this, so I may have some programming errors. This is the file of my C module:
#include <linux/linkage.h> #include <linux/time.h> #include <linux/module.h> asmlinkage long sys_mycall(int myid, char* firstname) { printk ("Hello, %s! \n sys_mycall called from process %d with ID %d. \n", firstname, current->id, myid); return 0; } static int my_init(void) { return 0; } static int my_exit(void) { printk("Goodbye!"); return 0; } module_init(sys_mycall); module_exit(my_exit);
First of all, I donβt know how exactly the arrow pointer works, so I usually omit it from printk , so it compiles fine. If someone can give me a link or something on how to understand it, I would really appreciate it.
When I insert it using insmod into the terminal and then output the message using dmesg , I get a module_init message that calls sys_mycall , but I can not add any arguments to it and it displays a message but it shows nothing for firstname or for myid .
c linux module terminal kernel
randomizertech
source share