module_init(), module_exit()는...

iris422의 이미지

init_module(), cleanup_module()로 잘 실행되는 샘플 모듈 프로그램을 module_init(), module_exit()로 바꾸어서 실행했더니 컴파일에서도 warning이 많이 나고.. 실행도 안되네여..
뭐가 문제일까여??

--> hello_init.c
int hello_init(void)
{
printk(KERN_ALERT "Hello, World\n");
return 0;
}
module_init(hello_init);

--> hello_exit.c
void hello_exit(void)
{
printk(KERN_ALERT "Goodbye\n");
}

module_exit(hello_exit);

소스 코드는 이렇구여..

make하면.. 아래와 같은 메시지가..
gcc -I/usr/src/linux-2.4/include -D__KERNEL__ -DMODULE -O -Wall -c -o hello_init.o hello_init.c
hello_init.c: In function `hello_init':
hello_init.c:19: warning: implicit declaration of function `printk_R1b7d4074'
hello_init.c: At top level:
hello_init.c:23: warning: type defaults to `int' in declaration of `module_init'
hello_init.c:23: warning: parameter names (without types) in function declaration
hello_init.c:23: warning: data definition has no type or storage class
gcc -I/usr/src/linux-2.4/include -D__KERNEL__ -DMODULE -O -Wall -c -o hello_cleanup.o hello_cleanu
p.c
hello_cleanup.c: In function `hello_exit':
hello_cleanup.c:19: warning: implicit declaration of function `printk_R1b7d4074'
hello_cleanup.c: At top level:
hello_cleanup.c:22: warning: type defaults to `int' in declaration of `module_exit'
hello_cleanup.c:22: warning: parameter names (without types) in function declaration
hello_cleanup.c:22: warning: data definition has no type or storage class
ld -r hello_init.o hello_cleanup.o -o hello.o

뜹니다. 끝나면 hello.o 가 만들어지구여..
그래서 insmod 하면 정상적으로 된 것처럼 보이구.. rmmod 잘 되는데.. /var/log/messages에는 결과가 안 보이네여..
왜 일까여???

pastime의 이미지

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

위의 세 줄을 소스의 제일 윗부분에 추가해 보시기 바랍니다.
iris422의 이미지

gcc -I/usr/src/linux-2.4/include -D__KERNEL__ -DMODULE -O -Wall -c -o hello_init.o hello_init.c
hello_init.c: In function `hello_init':
hello_init.c:20: warning: implicit declaration of function `printk_R1b7d4074'
gcc -I/usr/src/linux-2.4/include -D__KERNEL__ -DMODULE -O -Wall -c -o hello_cleanup.o hello_cleanu
p.c
hello_cleanup.c: In function `hello_exit':
hello_cleanup.c:20: warning: implicit declaration of function `printk_R1b7d4074'
ld -r hello_init.o hello_cleanup.o -o hello.o

왜.. 이런 warning이 나는 거져??