MODULE_DEPEND(9)

✨ MODULE_DEPEND πŸ’…

okay bestie, so this one is literally called MODULE_DEPEND and it's from the Kernel Developer's Manual, section 9 (iykyk, that's the kernel interface girlies πŸŽ€). it does exactly one thing and it does it iconically: it sets up kernel module dependencies. let's get into it πŸ¦‹


πŸ“š SYNOPSIS

first you gotta pull in the vibes:

#include <sys/param.h>
#include <sys/module.h>

then you hit 'em with:

MODULE_DEPEND(name, moddepend, int minversion, int prefversion,
    int maxversion);

🌸 DESCRIPTION

so the MODULE_DEPEND() macro sets a dependency on another kernel module, and that other module is called moddepend, and it has to have registered its version already with MODULE_VERSION(). no version registration, no dependency, that's the deal πŸ™ˆ

what MODULE_DEPEND() actually does is give hints to the kernel loader(8) and to the kernel linker β€” it's basically sliding into their DMs like "hey bestie, pls make sure this named dependency gets loaded before the existing module, mwah πŸ’–". and that's it. it does not change or dictate the order in which modules are initialized at runtime. like, loading order β‰  init order, don't get it twisted πŸ‘‘

you have to specify three versions for moddepend, and here's the breakdown:

  • minversion β€” the minimum version the current module can depend on. the floor. the bare minimum. periodt.
  • maxversion β€” the maximum version the current module can depend on. the ceiling, no cap fr.
  • prefversion β€” the preferred version the current module can depend on. the one you'd pick if you could pick πŸ’…

πŸ“ EXAMPLES

look at this little cutie go:

MODULE_DEPEND(foo, bar, 1, 3, 4);

so foo is depending on bar, and it'll accept versions 1 through 4, but it'd prefer 3. main character energy tbh 🌟


πŸ‘€ SEE ALSO

go read those too, they're all in the same friend group 🫢


πŸ‘‘ AUTHORS

this manual page was written by Alexander Langer <alex@FreeBSD.org> β€” absolute icon, we stan 🌈


πŸ’€ reminder bestie: this macro is a hint, not a runtime scheduling command. don't go telling people it orders your init, because it literally does not. fr fr.

and that's the whole page, we ate and left no crumbs πŸŽ€ this was Debian's version, dated January 11, 2005 β€” vintage but still slaying ✨ bye bestie, go write some kernel modules πŸ’œπŸ¦‹

πŸ“¦ where this page comes from