模块的源文件为hello.c,源码如下:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>
#define HELLO_MAJOR 231
#define DEVICE_NAME "HelloModule"
static int hello_open(struct inode *inode, struct file *file)
{
printk(KERN_EMERG "hello open.\n");
return 0;
}
static ssize_t hello_write(struct file *file