Reputation: 23666
From what I read, the purpose of depmod is to track dependencies for each kernel module for when it gets loaded. Why can't this be simply determined automatically when the kernel module is loaded, similar to dynamically loading a userspace shared library?
Upvotes: 9
Views: 8485
Reputation: 231373
depmod does more than just compute direct dependencies - it also builds a mapping between hardware identifiers and the modules that handle them. This is used to find the correct module to load for a detected piece of hardware.
As for why it doesn't do demand loading like userspace does, part of this is because the kernel linker is not allowed to access the filesystem, by design. The philosophy in the kernel is the layout of the filesystem is completely up to userspace, and so there's no guarantee that foo.ko
will be found in /lib/modules/3.0.1/drivers/somesubsys/foo.ko
. As such, the kernel relies on userspace utilities (like depmod and modprobe) to pass it the raw data for its modules, in the order it needs to load them; if userspace fails in this job, it simply returns an error, and lets userspace deal with the mess.
Upvotes: 16