一个简单的内核模块
编写一个内核模块,大体需要以下步骤:编写内核文件(一个或多个.c文件),编写Makefile,编译和加载。
下面进行详细介绍。
编写内核模块文件
先看一个简单的内核模块,路径及文件名为/opt/hello/hello.c。
#include <linux/init.h>
#include <linux/module.h>
int num = 100;
module_param(num, int, S_IRUGO);
static int __init hello_init(void)
{