3

I've created a basic linux kernel module, which does the following:

static __init int init(void)
{
  printk(KERN_DEBUG "Banana");
  return 0;
}

And of course:

module_init(init);

Strangely, I cannot find the string "Banana" after I insert the module via

insmod banana_module.ko

The command

dmesg -k | grep Banana

doesn't return anything.

I can find it however when I remove the module and insert it again. Then I find two bananas, the one from before and one from the current insertion. Is this due to flushing issues? I find this behavior a bit strange and couldn't find a similar problem on the internet.

Btw, this happens on both my virtual machine on my desktop and on my laptop (without a VM).

So, why doesn't the kernel like bananas?

3

I've figured out what the problem was:

I did not specify the endline character \n at the end of my kernel message. If you leave it out, it behaves like described above. The reason is, that kernel messages are rather seen as records that are only printed out when completed. For more information see this article about printk problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.