上QQ阅读APP看书,第一时间看更新
How it works...
The insmod command just takes our module and inserts it into the kernel; after that, it executes the module_init() function.
During module insertion, if we're over an SSH connection, we'll see nothing on the Terminal and we have to use dmesg to see kernel messages (or tail on the /var/log/kern.log file, as discussed previously); otherwise, on the serial console, after inserting the module, we should see something like the following:
dummy_code: loading out-of-tree module taints kernel.
dummy_code:dummy_code_init: dummy-code loaded
Note that the message, loading out-of-tree module taints kernel, is just a warning and can be safely ignored for our purposes. See https://www.kernel.org/doc/html/v4.15/admin-guide/tainted-kernels.html for further information about tainted kernels.
The rmmod command does the inverse steps of insmod, that is, it executes the module_exit() function and then removes the module from the kernel.