17.8.1.1. fops.c
This example illustrates the most basic system calls: open
, read
, write
, close
and lseek
.
In it we create a debugfs special file that behaves like a regular file, except that it is stored in memory for as long as the kernel module is loaded, and it has a fixed lengh of 4 bytes. Any longer write
attempt gets simply truncated up at the end:
./fops.sh echo $?
Outcome: the test passes:
0
Then give this a try:
sh -x ./fops.sh
We have put printks on each fop, so this allows you to see which system calls are being made for each command.
No, there no official documentation: https://stackoverflow.com/questions/15213932/what-are-the-struct-file-operations-arguments