user1384365
user1384365

Reputation: 43

about linux module printk

I write a module,and want add it to kernel.It will print a world when i insmod the module.but it will not...

the module as:

#include <linux/module.h>
#include <linux/init.h>

static int __init hello_init()
{
    printk(KERN_EMERG"Hello World!\n");
    return 0;
}

static void __exit hello_exit()
{
    printk("<6>hello exit\n");
}

module_init(hello_init);
module_exit(hello_exit);

why the "Hello World!\n" dose not print when i load the module?? Are there some one meet the question? thinks for your help....

Upvotes: 0

Views: 612

Answers (2)

Aaron Digulla
Aaron Digulla

Reputation: 328840

Since you didn't get a compile/linking error and insmod/modprobe didn't complain about missing symbols, there are two reasons why this can happen:

  1. Someone defined a macro printk()
  2. You looked in the wrong place. The text will be printed to the syslog. To see that, use dmesg | tail

Upvotes: 1

Coren
Coren

Reputation: 5647

Maybe it's a linking or a header problem.

It seems you haven't specified any license, too, which can be a problem.

You can try this site, especially about the linking and loading part.

Upvotes: 1

Related Questions