在系统内部,I/O设备等等存取通过一组固定的入口点来进行,这组入口点由每个
设备的设备驱动程序提供。在Linux系统里,设备驱动程序提供的入口点由一个结构来向系统进行说明,此结构体定义为:
Structfile_operations{
int (*lseek)(struct innode *innode, structfile *file,off_t off, int pos);
/*移动文件指针的位置*/
int (*read)(struct innode *innode, structfile *file, char *buf, int count);
/*读操作,buf为存放读取结果的缓冲区,count为要读取的数据长度*/
int (*write)(struct innode *innode, structfile *file, char *buf, int count);
/*写操作,与read类似*/
int (*readdir)(struct innode *innode, structfile *file, struct dirent *dirent, int count);
/*取得下一个目录入口点*/
int (*select)(struct innode *innode, structfile *file, int sel_type, select_table *wait);
/*检查设备,看数据是否可读或设备是否可用于写数据*/
int (*ioctl)(struct innode *innode, structfile