svn commit: r368728 - head/stand/lua

Kyle Evans kevans at FreeBSD.org
Thu Dec 17 18:24:38 UTC 2020


Author: kevans
Date: Thu Dec 17 18:24:36 2020
New Revision: 368728
URL: https://svnweb.freebsd.org/changeset/base/368728

Log:
  lualoader: cli: provide a show-module-options loader command
  
  This effectively dumps everything lualoader knows about to the console using
  the libsa pager; that particular lua interface was added in r368591.
  
  A pager stub implementation has been added that just dumps the output as-is
  as a compat shim for older loader binaries that do not have lpager. This
  stub should be moved into a more appropriate .lua file if we add anything
  else that needs the pager.

Modified:
  head/stand/lua/cli.lua
  head/stand/lua/cli.lua.8
  head/stand/lua/config.lua
  head/stand/lua/config.lua.8

Modified: head/stand/lua/cli.lua
==============================================================================
--- head/stand/lua/cli.lua	Thu Dec 17 18:15:07 2020	(r368727)
+++ head/stand/lua/cli.lua	Thu Dec 17 18:24:36 2020	(r368728)
@@ -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.
@@ -171,6 +183,61 @@ cli["toggle-module"] = function(...)
 
 	local module = argv[1]
 	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

Modified: head/stand/lua/cli.lua.8
==============================================================================
--- head/stand/lua/cli.lua.8	Thu Dec 17 18:15:07 2020	(r368727)
+++ head/stand/lua/cli.lua.8	Thu Dec 17 18:24:36 2020	(r368728)
@@ -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 a
 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 :

Modified: head/stand/lua/config.lua
==============================================================================
--- head/stand/lua/config.lua	Thu Dec 17 18:15:07 2020	(r368727)
+++ head/stand/lua/config.lua	Thu Dec 17 18:24:36 2020	(r368728)
@@ -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")

Modified: head/stand/lua/config.lua.8
==============================================================================
--- head/stand/lua/config.lua.8	Thu Dec 17 18:15:07 2020	(r368727)
+++ head/stand/lua/config.lua.8	Thu Dec 17 18:24:36 2020	(r368728)
@@ -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


More information about the svn-src-head mailing list