Writing file operations
After introducing the preceding file operations, it is time to implement them in order to enhance the driver capabilities and expose the device's methods to the user space (by means of system calls of course). Each of these methods has its particularities, which we will highlight in this section.
Exchanging data between kernel space and user space
This section does not describe any driver file operation but instead introduces some kernel facilities that you may use to write these driver methods. The driver's write()
method consists of reading data from user space to kernel space, and then processing that data from the kernel. Such processing could be something like pushing the data to the device, for example. On the other hand, the driver's read()
method consists of copying data from the kernel to the user space. Both of these methods introduces new elements we need to discuss prior to jumping to their respective steps.
The first one is __user
. __user
is a cookie used...