内核模块的编译、加载与卸载
来源:互联网 发布:java 抽象工厂类 编辑:程序博客网 时间:2024/05/18 13:07
1.放在drivers/char/下
拷贝hello.c到drivers/char/目录下
打开drivers/char/Makefile,在其中增加一行:
obj-m +=hello.o 或若有配置选项,增加如下一行:
obj-$(CONFIG_HELLO) += hello.o
打开配置文件drivers/char/Kconfig,在其中增加一项:
config HELLO
tristate “New Hello”
cd usr/src/linux-2.6.34.13/
make menuconfig
make modules
cd usr/src/linux-2.6.34.13/drivers/char/
insmod ./hello.ko
rmmod hello
cat /var/log/messages | grep world
2.
放在drivers/char/下的子目录中
在 drivers/char/下创建子目录hello
拷贝hello.c到drivers/char/hello/目录下
打开drivers/char/Makefile,在其中增加一行:
obj-m +=hello/ 或若有配置选项,增加如下一行:
obj-$(CONFIG_HELLO) += hello/
在drivers/char/hello/下新建Makefile,需一行:
obj-m += hello.o 或若有配置选项:
obj-$(CONFIG_HELLO) += hello.o
打开配置文件drivers/char/Kconfig,在其中增加一项:
config HELLO
tristate “New Hello”
make menuconfig
make modules
cd usr/src/linux-2.6.34.13/drivers/char/hello/
insmod ./hello.ko
rmmod hello
cat /var/log/messages | grep world
3.
放在内核源代码外
建hello目录,将hello.c与makefile放入其下,makefile中只需一行:
Obj-m :=hello.o
在hello目录下运行命令:
make -C ~/kernel-2.6 M=$PWD modules
make -C /usr/src/linux-2.6.34.13/ M=$PWDmodules
cd /home/ldd/hello/
insmod ./hello.ko
rmmod hello
cat /var/log/messages | grep world
4.
建hello目录,将hello.c与makefile放入其下,使用带条件语句的复杂makefile(见后)
# If KERNELRELEASE is defined, we've beeninvoked from the
# kernel build system and can use itslanguage.
ifneq ($(KERNELRELEASE),)
obj-m:= hello.o
# Otherwise we were called directly fromthe command
# line; invoke the kernel build system.
else
KERNELDIR?= /usr/src/linux-2.6.34.13/
PWD:= $(shell pwd)
default:
$(MAKE)-C $(KERNELDIR) M=$(PWD) modules
endif
在hello目录下运行命令:
make
cd /home/ldd/hello/
insmod ./hello.ko
rmmod hello
cat /var/log/messages | grep world
- 内核模块的编译、加载与卸载
- 内核模块的加载与卸载
- 内核模块的编写、编译、加载、卸载;Makefile的编写
- Linux内核模块的编译、加载和卸载
- 编译,加载并卸载一个内核模块
- linux下内核模块的加载与卸载
- 内核模块的加载和卸载
- Linux内核模块编译、加载&卸载及查看运行结果
- Linux内核模块编译、加载&卸载及查看运行结果
- 内核模块编写,编译,加载和卸载过程
- ubuntu下helloworld内核模块编译、加载/卸载
- Linux内核模块编译与加载
- 向内核加载/卸载模块
- linux内核模块的安装与卸载
- linux模块的加载与卸载
- 简单的内核模块编译、加载
- Linux内核模块的“加载”和“卸载”函数
- linux内核及其模块的查询,加载,卸载
- Android开发之--图片压缩的三种方式
- Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结
- ccc碰撞系统的一个小坑
- div 绝对定位覆盖
- Java 读书笔记 14.1-14.6 RTTI
- 内核模块的编译、加载与卸载
- android Comparator做排序
- HDU problem 5635 LCP Array【思维】
- linux 静态库与共享库
- LVS_NAT模式
- 【latin】mysql校对规则(COLLATION)详解
- TextView上下滚动实现通知效果
- 你真的了解一段Java程序的生命史吗?
- Unity中Button的颜色如何用脚本改变