Load a module, link it into the running kernel, and call the module's
modcmd() routine with a
cmd argument of
MODULE_CMD_INIT. If the specified module requires other modules, they are loaded first; if any required module cannot be loaded or if any of their
modcmd() control routines returns a non-zero status, loading of this module and the specific required module will fail. The required modules are marked for automatic unloading. Thus, if the loading of the module failed, the required modules will be automatically unloaded after a short delay.
The loader will look first for a built-in module with the specified
name that has not been disabled (see
module_unload() below). If a built-in module with that
name is not found, the list of modules prepared by the boot loader is searched. If the named module is still not found, an attempt is made to locate the module within the file system.
The
flags argument can include:
MODCTL_NO_PROP
When loading a module from the file system, do not attempt to locate a corresponding prop_dictionary file.
MODCTL_LOAD_FORCE
Force loading of disabled built-in modules and modules built for a different version of the operating system.
The
props argument points to an externalized property list which is passed to the module's
modcmd() routine. If a module is being loaded from the file system, and the
MODCTL_NO_PROP flag is not set, the system searches for a file with the same name as the module file, but with the suffix “
.prop”. If this file is found, the prop_dictionary it contains is loaded and merged with the prop_dictionary from the
props argument.
The
class argument can be any of:
MODULE_CLASS_DRIVER
Device driver
MODULE_CLASS_EXEC
Executable image handler
MODULE_CLASS_MISC
Miscellaneous module
MODULE_CLASS_VFS
Virtual file system
If the class is not
MODULE_CLASS_ANY, the class of the module being loaded must match the requested
class. Except when verifying a module's class when it is being loaded, module classes other than
MODULE_CLASS_SECMODEL are transparent to the module subsystem. They are provided only for the benefit of the subsystem's clients. Modules with class
MODULE_CLASS_SECMODEL are automatically registered with
secmodel_register() after being successfully loaded, and automatically deregistered with
secmodel_deregister() when being unloaded.
The
module_load() routine is primarily intended as the implementation of the
MODCTL_LOAD option of the
modctl(2) system call.