编写一个简单的linux内核模块
来源:互联网 发布:三星网络电视60寸价格 编辑:程序博客网 时间:2024/05/17 02:02
1. 首先,编写c程序helloworld.c:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int hello_init(void)
{
printk("<1>Hello World!\n");
return 0;
}
static void hello_exit(void)
{
printk("<1>Goodbye!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
2. 编写makefile:
obj-m:=helloworld.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
3. 运行命令make,产生如下文件:
helloworld.o Module.symvers helloworld.ko helloworld.mod.c helloworld.mod.o
4. 加载到内核:insmod helloworld.ko
5. 查看内核模块:lsmod | grep helloworld
Module Size Used by
helloworld 5504 0
6.移除模块: rmmod helloworld.ko
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int hello_init(void)
{
printk("<1>Hello World!\n");
return 0;
}
static void hello_exit(void)
{
printk("<1>Goodbye!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
2. 编写makefile:
obj-m:=helloworld.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
3. 运行命令make,产生如下文件:
helloworld.o Module.symvers helloworld.ko helloworld.mod.c helloworld.mod.o
4. 加载到内核:insmod helloworld.ko
5. 查看内核模块:lsmod | grep helloworld
Module Size Used by
helloworld 5504 0
6.移除模块: rmmod helloworld.ko
- 编写一个简单的linux内核模块
- 编写一个简单的内核模块
- 编写一个简单的内核模块
- 一个简单的Linux内核模块实现
- 一个简单的Linux内核模块
- 如何编写一个简单的linux内核模块和设备驱动程序
- 编写简单的内核模块
- 编写一个简单的内核模块程序Hello World!
- linux内核模块的编写
- 一个入门级的Linux内核模块编写
- Linux最简单内核模块编写
- 一个简单的内核模块编写到测试的全过程testmodule 之内核版本2.4.20.8
- 内核模块学习之简单的内核模块编写
- 一个最简单的Linux 2.6内核驱动模块
- 【Linux】【Kernel】一个简单的内核模块例子
- 编写Linux内核模块
- linux内核模块编写
- 编写Linux内核模块
- frameset 空白,iframe 空白边的解决方法
- android app 内存使用
- XML3
- 找工作应该记住的话……
- 空白的博客
- 编写一个简单的linux内核模块
- Ubuntu Server 11.04上安装RedMine+Subversion
- Windows下SVN服务器的搭建
- 【生活】
- 出现javax.servlet.ServletException: BeanUtils.populate异常
- 创建list(列表)分区!
- 学车总结
- 使IE6下PNG背景透明的方法
- STM32 GPIO 相关寄存器