Linux Module Stacking Example

What is module stacking?

New modules using the symbols exported by old modules.

Examples of modules stacking in Linux Kernel?


  • Msdos filesystem relies on symbols exported by fat module
  • Parallel port printer driver (lp) relies on symbols exported by generic parallel port driver (parport)

Let's write a sample device driver code which exports a function myadd performing addition of two numbers:


Code:


Now, we will write another module which uses the exported function:

Code:

Makefile to Compile two modules:


Build the modules by running "make", Load the first module and then second module using insmod.

Output:




Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto