Without further ado, here is some simple Hello, world C code, implemented to abide by the Linux kernel's LKM framework:
For reasons of readability and space constraints, only the key parts of the source code are displayed here. To view the complete source code, build it, and run it, the entire source tree for this book is available in it's GitHub repository here: https://github.com/PacktPublishing/Linux-Kernel-Programming. We definitely expect you to clone it:
git clone https://github.com/PacktPublishing/Linux-Kernel-Programming.git
git clone https://github.com/PacktPublishing/Linux-Kernel-Programming.git
// ch4/helloworld_lkm/hellowworld_lkm.c
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
MODULE_AUTHOR("<insert your name here>");
MODULE_DESCRIPTION("LLKD book:ch4/helloworld_lkm: hello, world, our first LKM");
MODULE_LICENSE("Dual MIT/GPL");
MODULE_VERSION("0.1");
static int __init helloworld_lkm_init...