kernel module: fix fops... and move its documentation into README

Sometimes I wonder if anyone has ever run this tutorial, otherwise how
can such basic bugs persist for so long?

test_all.sh: crete
This commit is contained in:
Ciro Santilli
2018-06-29 08:40:15 +01:00
parent 7f3671894f
commit 0cd1a2b602
7 changed files with 98 additions and 64 deletions

View File

@@ -2877,8 +2877,52 @@ You should then look up if there is a branch that supports that kernel. Staying
=== Pseudo filesystems
Pseudo filesystems are filesystems that don't represent actual files in a hard disk, but rather allow us to do special operations on filesystem-related system calls.
Some notable examples include:
* procfs, often mounted at: `/proc`
* sysfs, often mounted at: `/sys`
* devtmpfs, often mounted at: `/dev`
* debugfs, often mounted at: `/sys/kernel/debug/`
What each pseudo-file does for each related system call does is defined by its <<file-operations>>.
Bibliography:
* https://superuser.com/questions/1198292/what-is-a-pseudo-file-system-in-linux
* https://en.wikipedia.org/wiki/Synthetic_file_system
==== File operations
In guest:
....
/fops.sh
echo $?
....
Outcome: the test passes:
....
0
....
Sources:
* link:kernel_module/fops.c[]
* link:rootfs_overlay/fops.sh[]
File operations is the main method of userland driver communication.
`struct file_operations` determines what the kernel will do on filesystem system calls of <<pseudo-filesystems>>.
No, there no official documentation: http://stackoverflow.com/questions/15213932/what-are-the-struct-file-operations-arguments
==== Character device
In guest:
....
/character_device.sh
echo $?
@@ -7579,7 +7623,15 @@ Should:
* make a network request
* shutdown gracefully
TODO automate all of this with a `/test-all.sh` script in guest which outputs to stdout `LKMC_TEST_PASS` or `LKMC_TEST_FAIL` and grep that from host.
We are slowly automating testable guest tests with:
....
./run -F '/test_all.sh;/poweroff.out' | grep lkmc_test
....
which outputs to stdout `lkmc_test_pass` or `lkmc_test_fail` to stdout, which we can grep from host to automate testing.
Source: link:rootfs_overlay/test_all.sh[].
===== Host testing