In this recipe, we're going to take a better look at how we can manipulate the ppos pointer (described in the Exchanging data with a char driver recipe in Chapter 3, Working with Char Drivers), which is related to the read() and write() system call implementations.
Going up and down within a file with lseek()
Getting ready
To provide a simple example about lseek() implementation, we can reuse our chrdev driver in Chapter 4, Using the Device Tree in the chapter_04/chrdev directory (we need both of the chrdev.c and chrdev-req.c files of GitHub repository), where we can simply add our custom llseek() method according to our device memory layout.
For simplicity, I just copied these files in the chapter_07/chrdev/ directory...