linux ops 一些函数简介

1. int *(open) (struct inode *, struct file *)

如果该项为NULL,设备的打开操作永远成功

 

2.void (*release)(struct inode *, struct file *)

如果该项为NULL,设备的打开操作永远成功

 

3 int (*read) (struct inode *, struct file *, const char *, int)

对设备读取数据,当为NULL指针时,read返回-EINVAL,返回非负值为读取的字节数

 

4 int (*write) (struct inode *, struct file *, const char *, int)

对设备写入数据,当为NULL指针时,write返回-EINVAL

 

5 int (*select) (struct inode *, struct file *, int, select_table *)

用于询问设备是否可读可写

 

6 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long)

用于用户下发命令,内核无定义时,返回 -EINVAL,调用成功返回一个非负返回值

 

7 int (*mmap) (struct inode *, struct file *, struct vm_area_struct *)

mmap用来设备内存映射到进程内存中

 

8 int (*lseek) (struct inode *,struct file *, off_t, int)

修改文件当前读写位置,并将新的位置作为返回值。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值