Common operations on kernel modules
Now let’s delve into how exactly you can build, load, and unload a kernel module. Besides this, we’ll also walk through the basics regarding the tremendously useful printk()
kernel API, details on listing the currently loaded kernel modules with lsmod
, and a convenient script for automating some common tasks during kernel module development. So, let’s begin!
Building the kernel module
At the risk of repetition, we urge you to try out our simple Hello, world kernel module as an exercise (if you haven’t already done so)! To do so, we assume you have cloned this book’s GitHub repository (https://github.com/PacktPublishing/Linux-Kernel-Programming_2E) already. If not, please do so now (refer to the Technical requirements section for details).
Here, we show, step by step, how exactly you can build and then insert our very first kernel module into kernel memory. Again, a quick reminder: we have...