escape
驱动老牛
驱动老牛
  • 注册日期2002-02-01
  • 最后登录2004-08-20
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1119回复:2

linux下,客户程序如何打开驱动程序?

楼主#
更多 发布于:2003-03-25 14:36
是应该用open()函数吗?文件名参数该怎样设置呢?
escape
驱动老牛
驱动老牛
  • 注册日期2002-02-01
  • 最后登录2004-08-20
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2003-03-25 15:58
解释得很完备。分全给你啦。 :)
hometown
驱动大牛
驱动大牛
  • 注册日期2002-10-24
  • 最后登录2004-05-21
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-03-25 14:54
参见你自己的帖子“SHELL。。。”。 这里我可以具体点给你一个回答。 一般设备都对应一个INODE, 这个INODE存在于文件系统中, 网络设备不一样, 网络设备只在内存中创建一个INODE, 没有对应的硬盘映象(假设存储系统的设备是硬盘, 下同), 不过操作基本一样, 除了它不从硬盘读取INODE信息外。 当你打开一个设备时, 假定是/dev/realdev, 这时系统搜索目录, 然后找出该文件对应的INODE号, 然后从硬盘上找到该接点, 在内存中初始化一个INODE, 其结构是struct inode, 参看linuxsourcecode/include/linux/fs.h。 然后OS查看该进程的fd使用情况, 用函数get_fd()获取一个可用的fd, 最后初始化一个struct file, 用INODE中的inode_operations中的file_operations来初始化struct file 中的file_operations, 实际上就是用硬盘driver提供的接口来完成这个动作的, 比如你使用open, 这是一个包裹函数, 它对应的系统调用是sys_open, 而sys_open中使用的回调技术, 这是通过虚拟文件系统(VFS)的技术来实现的, 这时实际上是调用current -> files -> fd[fd] -> open(...), 而这里的open就是硬盘driver提供的open操作。

不知道你明白没有?  :D :D :D :D
How fair and how pleasant art thou, O love, for delights!This thy stature is like to a palm tree, and thy breasts to clusters of grapes.I said, I will go up to the palm tree, I will take hold of the boughs thereof: now also thy breasts shall be as clusters of the vine, and the smell of thy nose like apples;And the roof of thy mouth like the best wine for my beloved, that goeth down sweetly, causing the lips of those that are asleep to speak.
游客

返回顶部