MODULE_DEPEND(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’œ MODULE_DEPEND(9) β€” kernel module dependency vibes

okay bestie, welcome to the Kernel Developer's Manual ✨ this one's a 9 section page, i.e. kernel-land, and it's all about MODULE_DEPEND β€” the macro that lets your kernel module say "hey, I need that other module, no cap." πŸŽ€


🌸 NAME

MODULE_DEPEND β€” set kernel module dependencies 🫢


✨ SYNOPSIS

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

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

Like, yes, prefversion comes before maxversion in the actual call β€” that's the order, don't come for me πŸ’…


πŸ’– DESCRIPTION

So the MODULE_DEPEND() macro sets a dependency on another kernel module with name moddepend, and that module must have registered its version with MODULE_VERSION(). That's the whole vibe check: no version registered, no dependency, periodt.

What MODULE_DEPEND() actually does is give hints to the kernel loader(8) and to the kernel linker so the named dependency gets loaded prior to the existing module, fr fr. It's giving main character energy for load order.

but like, important: it does not change or dictate the order in which modules are initialized at runtime. Loading order β‰  init order, bestie, they're different things 😭

Three versions must be specified for moddepend, and honestly you need all three:

  • minversion β€” the minimum version on which the current module can depend.
  • maxversion β€” the maximum version on which the current module can depend.
  • prefversion β€” the preferred version on which the current module can depend.

(the original page lists them in that order, so that's the order I'm giving you πŸ’œ)


πŸ¦‹ EXAMPLES

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

that's it, that's the example β€” foo depends on bar, min 1, pref 3, max 4. slay πŸ”₯


πŸ‘‘ SEE ALSO

go read those next, iykyk πŸ“š


🌈 AUTHORS

This manual page was written by Alexander Langer <alex@FreeBSD.org>. iconic behavior, ty for your service 🫑


mwah, that's the page πŸ’… from the Debian crew, dated January 11, 2005 β€” yes she's vintage, and she still says MODULE_DEPEND(9) at the bottom, as she should πŸŽ€βœ¨

πŸ“¦ where this page comes from