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

扫描二维码关注公众号,回复: 5527983 查看本文章

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)

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

猜你喜欢

转载自blog.csdn.net/qq_33600019/article/details/85300926