linux ops 一些函数简介
1. int *(open) (struct inode *, struct file *)
如果該項(xiàng)為NULL,設(shè)備的打開操作永遠(yuǎn)成功
?
2.void (*release)(struct inode *, struct file *)
如果該項(xiàng)為NULL,設(shè)備的打開操作永遠(yuǎn)成功
?
3 int (*read) (struct inode *, struct file *, const char *, int)
對(duì)設(shè)備讀取數(shù)據(jù),當(dāng)為NULL指針時(shí),read返回-EINVAL,返回非負(fù)值為讀取的字節(jié)數(shù)
?
4 int (*write) (struct inode *, struct file *, const char *, int)
對(duì)設(shè)備寫入數(shù)據(jù),當(dāng)為NULL指針時(shí),write返回-EINVAL
?
5 int (*select) (struct inode *, struct file *, int, select_table *)
用于詢問設(shè)備是否可讀可寫
?
6 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long)
用于用戶下發(fā)命令,內(nèi)核無定義時(shí),返回 -EINVAL,調(diào)用成功返回一個(gè)非負(fù)返回值
?
7 int (*mmap) (struct inode *, struct file *, struct vm_area_struct *)
mmap用來設(shè)備內(nèi)存映射到進(jìn)程內(nèi)存中
?
8 int (*lseek) (struct inode *,struct file *, off_t, int)
修改文件當(dāng)前讀寫位置,并將新的位置作為返回值。
?
總結(jié)
以上是生活随笔為你收集整理的linux ops 一些函数简介的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: App Ops
- 下一篇: 用智能TFT液晶模块这种串口屏做产品界面