Emulating “library-like” features for kernel modules
One of the major differences between user-mode and kernel-mode programming is the complete absence of the familiar “library” concept in the latter. Libraries are essentially a collection or archive of APIs, conveniently allowing developers to meet these important goals: do not reinvent the wheel, software reuse, modularity, portability and the like. But within the Linux kernel, libraries – in the traditional sense of the word – just do not exist. Having said that, the lib/
folder within the kernel source tree contains library-like routines, several of which get built into the kernel image and are thus available to kernel/module developers at runtime.
The good news is that, broadly speaking, there are two techniques by which you can achieve “library-like” functionality in kernel space for your kernel modules:
- The first technique is by explicitly “linking...