I'm learning Linux Kernel programming. I'm trying to build my module from multiple files. It builds and loads, but there is no messages in dmesg. What is going wrong?
solution.c:
#include <linux/init.h>
#include <linux/module.h>
#include "checker.h"
static const char* msg = "Hello from my module!";
extern void call_me(const char*);
static int __init init(void)
{
printk(KERN_INFO "322\n");
call_me(msg);
printk(KERN_ALERT "After the function\n");
return 0;
}
static void __exit exitFromModule(void)
{
printk(KERN_ALERT "BYE\n");
return;
}
module_init(init);
module_exit(exitFromModule);
checker.h:
#include <linux/module.h>
void call_me(const char* str);
checker.c:
#include "checker.h" #include <linux/kernel.h>
void call_me(const char* str)
{
printk("<1>FROM CALL_ME!\n");
return;
}
Makefile:
CURRENT = $(shell uname -r)
KDIR = /lib/modules/$(CURRENT)/build
PWD = $(shell pwd)
DEST = /lib/modules/$(CURRENT)/misc
TARGET = solution
obj-m := $(TARGET).o
solution-objs := checker.o
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
@rm -f *.o .*.cmd .*.flags *.mod.c *.order;
@rm -f .*.*.cmd *.symvers *~ *.*~ TODO.*
@rm -fR .tmp*
@rm -rf .tmp_versions
After that i start make and it compiles. But after insmod there is messages in dmesg.