Hands-on Linux kernel module and character device driver development, working through the boundary between user space and kernel space.
The modules build up from a bare "hello world" in kernel space to a working character device driver. Each one isolates a single idea so it's clear what changed.
| Module | What it demonstrates |
|---|---|
hello_kernel |
A minimal loadable module with init/exit and printk |
hello_mod |
Module metadata, licensing, and the build basics |
mod_parameter |
Passing parameters at insmod time |
dev_num |
Registering and allocating device numbers (major/minor) |
chardev |
A full character device driver: dynamic major/minor allocation plus open, read, write, and release |
- Loadable kernel modules and the module lifecycle
- Dynamic device-number allocation
- The
file_operationsinterface and the VFS entry points - Moving data across the user/kernel boundary with
copy_to_userandcopy_from_user - Kernel logging through
printkanddmesg
- Linux kernel headers (
linux-headers-$(uname -r)) gccandmake
cd chardev # or any module folder
make # builds the .ko against the running kernel
sudo insmod chardev.ko
dmesg | tail # view the kernel log output
sudo rmmod chardevA word of caution: build against a matching kernel-headers version, and load modules on a VM or test machine rather than anything you care about.
Linux kernel, device drivers, character devices, kernel modules, the file_operations
interface, user and kernel space, system calls, and C.