LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 783|回复: 0

请教一个有关于red hat 8.0下的设备编程的问题

[复制链接]
发表于 2003-3-12 19:28:30 | 显示全部楼层 |阅读模式
本人最近在学习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>
请各位高手帮帮小弟我:(
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表