- 论坛徽章:
- 0
|
源代码- #include<linux/init.h>
- #include<linux/module.h>
- MODULE_LICENSE("Dual BSD/GPL");
- static int hello_init(void){
- printk(KERN_ALERT "Hello,world\n");
- return 0;
- }
- static void hello_exit(void){
- printk(KERN_ALERT "Goodbye,world\n");
- }
- module_init(hello_init);
- module_exit(hello_exit);
复制代码 大家直接看结果吧
[root@localhost Linux]# cd driver
[root@localhost driver]# make
make -C /lib/modules/2.6.9-67.ELsmp/build M=/mnt/hgfs/Linux/driver modules
make[1]: Entering directory `/usr/src/kernels/2.6.9-67.EL-smp-i686'
Building modules, stage 2.
MODPOST
make[1]: Leaving directory `/usr/src/kernels/2.6.9-67.EL-smp-i686'
[root@localhost driver]# /sbin/insmod hello.ko
[root@localhost driver]# /sbin/rmmod hello.ko
[root@localhost driver]#
为什么没有打印出Hello,world?
谢谢大家了啊~ |
|