How to make one Linux kernel module depend on another external module with depmod?

痴心易碎 提交于 2019-11-28 04:29:32

问题


I'm writing a kernel module which depends on one existing kernel module. I'm building my module out of the tree (as an external module).

How can I declare the dependency, so that it is recognized by depmod?


回答1:


While not entirely satisfying, the best I've come up with to make modprobe work is either adding an entry to modules.dep

# tail -1 modules.dep
../../../../home/ctuffli/mymod/mymod.ko: kernel/drivers/scsi/libsas/libsas.ko kernel/drivers/scsi/scsi_transport_sas.ko

or alternatively, symbolically linking the out-of-tree module to /lib/modules/ and let depmod figure out the dependencies

# ln -s /home/ctuffli/mymod/mymod.ko /lib/modules/2.6.31-19-server/kernel/drivers/scsi/
# depmod
# grep mymod /lib/modules/2.6.31-19-server/modules.dep
kernel/drivers/scsi/mymod.ko: kernel/drivers/scsi/libsas/libsas.ko kernel/drivers/scsi/scsi_transport_sas.ko



回答2:


You don't need to. depmod will run through all modules in the current /lib/modules/ directory and build it's dependency tree based on unresolved symbols.

By default it will assume any symbol not provided by another module is in the kernel however you can use the -e/-F options to check that is the case too.



来源:https://stackoverflow.com/questions/2237871/how-to-make-one-linux-kernel-module-depend-on-another-external-module-with-depmo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!