summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-12-17 18:24:36 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-12-17 18:24:36 +0000
commit7ed84fa14b00cdacfe9b43019cba7a14b33af352 (patch)
tree5f4c3cb413e76a0b8603762c30f4ea41632bebc3
parent3326f7e9bbd94a5059d104122bc5204108b3f448 (diff)
downloadsrc-test2-7ed84fa14b00cdacfe9b43019cba7a14b33af352.tar.gz
src-test2-7ed84fa14b00cdacfe9b43019cba7a14b33af352.zip
Notes
-rw-r--r--stand/lua/cli.lua67
-rw-r--r--stand/lua/cli.lua.88
-rw-r--r--stand/lua/config.lua7
-rw-r--r--stand/lua/config.lua.811
4 files changed, 91 insertions, 2 deletions
diff --git a/stand/lua/cli.lua b/stand/lua/cli.lua
index caf7d6476a46..9ed26af4b700 100644
--- a/stand/lua/cli.lua
+++ b/stand/lua/cli.lua
@@ -32,6 +32,18 @@ local core = require("core")
local cli = {}
+if not pager then
+ -- shim for the pager module that just doesn't do it.
+ -- XXX Remove after 12.2 goes EoL.
+ pager = {
+ open = function() end,
+ close = function() end,
+ output = function(str)
+ printc(str)
+ end,
+ }
+end
+
-- Internal function
-- Parses arguments to boot and returns two values: kernel_name, argstr
-- Defaults to nil and "" respectively.
@@ -173,6 +185,61 @@ cli["toggle-module"] = function(...)
setModule(module, not config.isModuleEnabled(module))
end
+cli["show-module-options"] = function()
+ local module_info = config.getModuleInfo()
+ local modules = module_info['modules']
+ local blacklist = module_info['blacklist']
+ local lines = {}
+
+ for module, info in pairs(modules) do
+ if #lines > 0 then
+ lines[#lines + 1] = ""
+ end
+
+ lines[#lines + 1] = "Name: " .. module
+ if info.name then
+ lines[#lines + 1] = "Path: " .. info.name
+ end
+
+ if info.type then
+ lines[#lines + 1] = "Type: " .. info.type
+ end
+
+ if info.flags then
+ lines[#lines + 1] = "Flags: " .. info.flags
+ end
+
+ if info.before then
+ lines[#lines + 1] = "Before load: " .. info.before
+ end
+
+ if info.after then
+ lines[#lines + 1] = "After load: " .. info.after
+ end
+
+ if info.error then
+ lines[#lines + 1] = "Error: " .. info.error
+ end
+
+ local status
+ if blacklist[module] and not info.force then
+ status = "Blacklisted"
+ elseif info.load == "YES" then
+ status = "Load"
+ else
+ status = "Don't load"
+ end
+
+ lines[#lines + 1] = "Status: " .. status
+ end
+
+ pager.open()
+ for i, v in ipairs(lines) do
+ pager.output(v .. "\n")
+ end
+ pager.close()
+end
+
-- Used for splitting cli varargs into cmd_name and the rest of argv
function cli.arguments(...)
local argv = {...}
diff --git a/stand/lua/cli.lua.8 b/stand/lua/cli.lua.8
index 0fafec9add4a..390831d21452 100644
--- a/stand/lua/cli.lua.8
+++ b/stand/lua/cli.lua.8
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 12, 2020
+.Dd December 17, 2020
.Dt CLI.LUA 8
.Os
.Sh NAME
@@ -96,6 +96,8 @@ module provides the following default commands:
.Ic disable-module
.It
.Ic toggle-module
+.It
+.Ic show-module-options
.El
.Pp
For
@@ -125,6 +127,10 @@ commands manipulate the list of modules to be loaded along with the kernel.
Modules blacklisted are considered disabled by
.Ic toggle-module .
These commands will override any such restriction as needed.
+The
+.Ic show-module-options
+command will dump the list of modules that loader has been made aware of and
+any applicable options using paged output.
.Ss Exported Functions
The following functions are exported from
.Nm :
diff --git a/stand/lua/config.lua b/stand/lua/config.lua
index c7a638dd6534..2eb10f7c7727 100644
--- a/stand/lua/config.lua
+++ b/stand/lua/config.lua
@@ -721,6 +721,13 @@ function config.isModuleEnabled(modname)
return not blacklist[modname]
end
+function config.getModuleInfo()
+ return {
+ modules = modules,
+ blacklist = getBlacklist()
+ }
+end
+
hook.registerType("config.loaded")
hook.registerType("config.reloaded")
hook.registerType("kernel.loaded")
diff --git a/stand/lua/config.lua.8 b/stand/lua/config.lua.8
index 059cc49fe42a..4fc51c90045f 100644
--- a/stand/lua/config.lua.8
+++ b/stand/lua/config.lua.8
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 12, 2020
+.Dd December 17, 2020
.Dt CONFIG.LUA 8
.Os
.Sh NAME
@@ -203,6 +203,15 @@ will be loaded during
.Fn config.loadelf .
It checks both that the module is marked for loading and that it is either
forced or not blacklisted.
+.It Fn config.getModuleInfo
+Returns a table with
+.Dq modules
+and
+.Dq blacklist
+tables describing the modules that the config module has been made aware of via
+.Xr loader.conf 5
+as well as a representation of
+.Ar module_blacklist .
.El
.Ss Defined Hooks
The following hooks are defined in