# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

#### 17.8.1. File operations

File operations are the main method of userland driver communication.

`struct file_operations` determines what the kernel will do on filesystem system calls of Pseudo filesystems.

This example illustrates the most basic system calls: `open`, `read`, `write`, `close` and `lseek`:

    ./fops.sh
    echo $?

Outcome: the test passes:

    0

Sources:

- kernel_modules/fops.c

- rootfs_overlay/lkmc/fops.sh

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