OS TUTORIALS: LINUX KERNEL MODULE DEPENDENCY ENTRIES (Modules.dep)

0 komentar

With Linux kernel supporting dynamic insertion of kernel modules at runtime (Loadable Kernel Modules – LKM), it becomes absolute necessity for it to be capable of also loading the dependencies modules for the module under insertion.


This is achieved by the Linux kernel using modprobe helper tool. The modprobe tool would take a look at all the dependencies that exists for the current loadable module and inserts all those dependency modules first, prior to the loading of the loadable module. In order to achieve this, the Linux kernel makes use of another tool called the “depmod” tool which auto-generates a file called the “modules.dep” containing a list of all the dependencies for various loadable modules.
The syntax of the modules.dep file is as follows:

{loadable module file}: {dependency module1} {dependency module2} {dependency module3}… etc

(Any blank line or the lines beginning with a # is ignored)

Using this file, the modprobe tool would load each of the dependency modules first, starting from the modules on the right most side in the above line and loading each of the modules while moving to the left. Thus ensuring that all the dependent modules are loaded prior to loading your loadable module file.

Yet another example as seen in the modules.dep man page is listed below:

For example, if /lib/modules/2.6.29/kernel/a.ko depended on b.ko and c.ko in the same directory, and c.ko depended on b.ko as well, the file might look like:

# This is a comment.

/lib/modules/2.6.29/kernel/a.ko: /lib/modules/2.6.29/kernel/c.ko /lib/modules/2.6.29/kernel/b.ko

/lib/modules/2.6.29/kernel/b.ko:

/lib/modules/2.6.29/kernel/c.ko: /lib/modules/2.6.29/kernel/b.ko

Knowing the syntax and the working of this file will be advantageous if you are debugging or hacking your LKM. The most common issue one could see during module insertion that reads:

“insmod: error inserting ‘/lib/xxx.ko’: -1 Unknown symbol in module”


Can be attributed to missing symbols due to module loading dependencies and can be fixed off by adding dependency entries for your module in the modules.dep file.

Share this article :

Post a Comment

 
Support : animeindo
Copyright © 2011. sakurateateamofficialpage - All Rights Reserved
Template Created by Creating Website Proudly powered by Blogger