如何使用 depmod 使一个 Linux 内核模块依赖于另一个外部模块? [英] How to make one Linux kernel module depend on another external module with depmod?

查看:29
本文介绍了如何使用 depmod 使一个 Linux 内核模块依赖于另一个外部模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个内核模块,它依赖于一个现有的内核模块.我正在从树中构建我的模块(作为外部模块).

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).

如何声明依赖项,使其被 depmod 识别?

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

推荐答案

虽然不完全令人满意,但我想出的让 modprobe 工作的最佳方法是向 添加一个条目模块.dep

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

或者,象征性地将树外模块链接到 /lib/modules/ 并让 depmod 找出依赖关系

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

这篇关于如何使用 depmod 使一个 Linux 内核模块依赖于另一个外部模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆