f_pos
定义在file
结构体(定义在<linux/fs.h>
),表示文件当前的读写位置:
struct file {
......
loff_t f_pos;
......
}
LDD3
中关于f_pos
的描述:
loff_t f_pos;
The current reading or writing position. loff_t is a 64-bit value on all platforms ( long long in gcc terminology). The driver can read this value if it needs to know the current position in the file but should not normally change it; read and write should update a position using the pointer they receive as the last argument instead of acting on filp->f_pos directly. The one exception to this rule is in the llseek method, the purpose of which is to change the file position.
驱动的读写操作不需要直接更新filp->f_pos
。关于其中原因,可参考这篇笔记。