ÎÒÏÂÔØÁËÒ»¸ölinux-2.6.31.5µÄÄںˣ¬½øÐÐÁ˱àÒë
È»ºó¿ªÊ¼±àд×Ô¼ºµÄÐéÄâ×Ö·ûÉ豸Çý¶¯
/**
*rwbuf.h, driver for virtual char-device
*/
#define RWBUF_NAME "rwbuf" // É豸Îļþ /dev/rwbuf
#define RWBUF_DEV "/dev/rwbuf" // device path
#define RWBUF_MAJOR 60 // Ö÷É豸ºÅ
#define RWBUF_CLEAR 0x909090 // IO Ctrl Command
ÉÏÃæÊǺêµÄÍ·Îļþ
#include "rwbuff.h"
#include <unistd.h>
#include <linux/kernel.h> //for kernel programming
#include <linux/module.h> //for kernel module struct
#include <linux/init.h>
#include <linux/fs.h> //struct file_operations
#include <sys/types.h>
static struct file_operations rwbuf_fpos = {
open: rwbuf_open,
release: rwbuf_close,
read: rwbuf_read,
write: rwbuf_write,
ioctl: rwbuf_ioctl,
};
int init_module()
{
printk("Hello world\n");
if(register_chrdev(RWBUF_MAJOR,RWBUF_NAME,&rwbuf_fpos)){
printk("register error\n");
return -1;
}
else
printk("register ok\n");
return 0;
}
void cleanup_module()
{
ÎÒ֮ǰÖÆ×÷µÄlinux×Ô¶¯°²×°isoÒѾ³É¹¦ÁË£¬ÏÖÔÚÏë¶ÔÆä½øÐÐһЩ¶¨ÖÆÐ޸ģ¬±ÈÈ磬¸ü¸ÄgrubͼƬµÈ¡£
ÎÒÔÚks.cfgµÄ%post¶ÎÀïÃæÊÇÕâÑùдµÄ£º
%post --nochroot
# Move the contents of the tar into their new locati ......