|
本人最近在学习linux下设备编程,但是总是搞不清楚struct file_operations{}
我在函数头先定义了这样的结构
struct file_operations {
int (*open)(struct inode *inode,struct file *file);
int (*release)(struct inode *inode,struct file *file);
ssize_t (*read)(struct file *file,char *buffer,size_t length,loff_t *offset);
ssize_t (*write)(struct file *file,const char *buffer,size_t length,loff_t *offset);
};
我给响应的函数编的可调用的函数是device_open,device_release,device_read,device_write这样四个函数
最后提供给文件系统的接口是
struct file_operations fops={
open: device_open,
release: device_release,
read: device_read,
write: device_write
};
我在gcc下编译但是怎么看不到得到的*.o文件,当我进行动态的加载连接的时候提示我的版本是2。4。9的但是我现在的内核是2。4。18的请问这是怎么搞的?我定义的头文件是
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/wrapper.h>
请各位高手帮帮小弟我:( |
|