一、从应用层到驱动层
应用程序中的原型为:
int _llseek(unsigned int fd, unsigned long offset_high,
unsigned long offset_low, loff_t *result,
unsigned int whence);
系统调用流程为:
loff_t vfs_llseek(struct file *file, loff_t offset, int whence)
{
if (!(file->f_mode & FMODE_LSEEK))
/*如果file->f_mode中的标志没有设置,则直接返回错误码。因为设备文件的open操作
默认是设置FMODE_LSEEK标志的*/
return -ESPIPE;
/*否则调用驱动程序中llseek的原型,由此可见驱动中需要根据用户传入的偏移值offset和调整
的起始位置参数来决定如何定位文件*/
return file->f_op->llseek(file, offset, whence);
}
static off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence)
{
off_t retval;
struc