From 0db2ca0c31983b2ca94e57b695a0b29277ab2daf Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sat, 25 Jan 2020 03:52:16 +0000 Subject: [PATCH] lua: add modules.loaded hook This may be used for the local module to hook in and load any additional modules that it wants, since it can't modify the modules table internal to config. We may consider adding API to do so at a later time, but I suspect it will be more complicated to use with little return. status is captured but ignored for the purpose of loading the hook. status will be false if *any* module failed to load, but we typically don't let that halt the boot so there's no reason to let it halt hooks. Some vendors or setups may have expected fails that would be actively thwarted by checking it. We may, at a later date, consider adding an API for letting non-config modules check which modules have successfully (or not) loaded in case an unexpected failure *should* halt whatever they are doing. MFC after: 3 days --- stand/lua/config.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stand/lua/config.lua b/stand/lua/config.lua index 873e778810b..77603ee24c8 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -623,7 +623,7 @@ end function config.loadelf() local xen_kernel = loader.getenv('xen_kernel') local kernel = config.kernel_selected or config.kernel_loaded - local loaded + local loaded, status if xen_kernel ~= nil then print(MSG_XENKERNLOADING) @@ -640,9 +640,12 @@ function config.loadelf() end print(MSG_MODLOADING) - return loadModule(modules, not config.verbose) + status = loadModule(modules, not config.verbose) + hook.runAll("modules.loaded") + return status end hook.registerType("config.loaded") hook.registerType("config.reloaded") +hook.registerType("modules.loaded") return config