Re: svn commit: r368575 - head/stand/lua
On Sat, Dec 12, 2020 at 8:17 AM Toomas Soome wrote: > > On 12. Dec 2020, at 16:10, Kyle Evans wrote: > > > > On Sat, Dec 12, 2020 at 1:35 AM Toomas Soome wrote: > >> > >> How about ’show-module-options’? > >> > >> rgds, > >> toomas > >> > > > > I missed that one. My 4th is a bit rusty, but it looks like this > > should just be enumerating over config's local modules table and > > dumping everything in sight? > > > > Yes, with pager or it is a bit useless. > Hmm... we don't currently expose the pager routines to lua, so I'll write a quick pager module to do so. I'll write the lua-side to use the pager if it's available but fallback to dumping it all out otherwise (which, thinking about the modules I typically have installed and looking at a test-run of 4thloader's show-module-options on an even more minimal system, 100% agree). ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r368575 - head/stand/lua
Yes, with pager or it is a bit useless. Sent from my iPhone > On 12. Dec 2020, at 16:10, Kyle Evans wrote: > > On Sat, Dec 12, 2020 at 1:35 AM Toomas Soome wrote: >> >> How about ’show-module-options’? >> >> rgds, >> toomas >> > > I missed that one. My 4th is a bit rusty, but it looks like this > should just be enumerating over config's local modules table and > dumping everything in sight? > > Thanks, > > Kyle Evans ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r368575 - head/stand/lua
On Sat, Dec 12, 2020 at 1:35 AM Toomas Soome wrote: > > How about ’show-module-options’? > > rgds, > toomas > I missed that one. My 4th is a bit rusty, but it looks like this should just be enumerating over config's local modules table and dumping everything in sight? Thanks, Kyle Evans ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r368575 - head/stand/lua
How about ’show-module-options’? rgds, toomas > On 12. Dec 2020, at 07:57, Kyle Evans wrote: > > Author: kevans > Date: Sat Dec 12 05:57:42 2020 > New Revision: 368575 > URL: https://svnweb.freebsd.org/changeset/base/368575 > > Log: > lualoader: provide module-manipulation commands > > Specifically, we have: > - enable-module > - disable-module > - toggle-module > > These can be used to add/remove modules to be loaded or force modules to be > loaded in spite of modules_blacklist. In the typical case, a user is > expected to use them to recover an issue happening due to a module directive > they've added to their loader.conf or because they discover that they've > under-specified what to load. > > MFC after: 1 week > > 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.luaSat Dec 12 02:26:43 2020(r368574) > +++ head/stand/lua/cli.luaSat Dec 12 05:57:42 2020(r368575) > @@ -65,6 +65,14 @@ local function parseBootArgs(argv, with_kernel) > end > end > > +local function setModule(module, loading) > + if loading and config.enableModule(module) then > + print(module .. " will be loaded") > + elseif not loading and config.disableModule(module) then > + print(module .. " will not be loaded") > + end > +end > + > -- Declares a global function cli_execute that attempts to dispatch the > -- arguments passed as a lua function. This gives lua a chance to intercept > -- builtin CLI commands like "boot" > @@ -132,6 +140,37 @@ end > > cli['reload-conf'] = function() > config.reload() > +end > + > +cli["enable-module"] = function(...) > + local _, argv = cli.arguments(...) > + if #argv == 0 then > + print("usage error: enable-module module") > + return > + end > + > + setModule(argv[1], true) > +end > + > +cli["disable-module"] = function(...) > + local _, argv = cli.arguments(...) > + if #argv == 0 then > + print("usage error: disable-module module") > + return > + end > + > + setModule(argv[1], false) > +end > + > +cli["toggle-module"] = function(...) > + local _, argv = cli.arguments(...) > + if #argv == 0 then > + print("usage error: toggle-module module") > + return > + end > + > + local module = argv[1] > + setModule(module, not config.isModuleEnabled(module)) > 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 Sat Dec 12 02:26:43 2020(r368574) > +++ head/stand/lua/cli.lua.8 Sat Dec 12 05:57:42 2020(r368575) > @@ -26,7 +26,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd September 13, 2019 > +.Dd December 12, 2020 > .Dt CLI.LUA 8 > .Os > .Sh NAME > @@ -77,14 +77,26 @@ This function may be invoked by a user at the loader p > .Ic foo . > Arguments may be passed to it as usual, space-delimited. > .Ss Default Commands > -As of present, the > +The > .Nm > -module by default provides commands for > -.Ic autoboot , > -.Ic boot , > -.Ic boot-conf , > -and > -.Ic reload-conf . > +module provides the following default commands: > +.Bl -bullet > +.\"-width toggle-module -offset indent > +.It > +.Ic autoboot > +.It > +.Ic boot > +.It > +.Ic boot-conf > +.It > +.Ic reload-conf > +.It > +.Ic enable-module > +.It > +.Ic disable-module > +.It > +.Ic toggle-module > +.El > .Pp > For > .Ic autoboot , > @@ -103,6 +115,16 @@ The > command will reload the configuration from disk. > This is useful if you have manually changed currdev and would like to easily > reload the configuration from the new device. > +.Pp > +The > +.Ic enable-module , > +.Ic disable-module , > +and > +.Ic toggle-module > +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. > .Ss Exported Functions > The following functions are exported from > .Nm : > > Modified: head/stand/lua/config.lua > == > --- head/stand/lua/config.lua Sat Dec 12 02:26:43 2020(r368574) > +++ head/stand/lua/config.lua Sat Dec 12 05:57:42 2020(r368575) > @@ -312,7 +312,7 @@ local function loadModule(mod, silent) > for k, v in pairs(mod) do > if v.load ~= nil and v.load:lower() == "yes" then > local module_name = v.name or k > - if blacklist[module_name] ~= nil then > + if not v.force and blacklist[module_name] ~= nil then >
svn commit: r368575 - head/stand/lua
Author: kevans Date: Sat Dec 12 05:57:42 2020 New Revision: 368575 URL: https://svnweb.freebsd.org/changeset/base/368575 Log: lualoader: provide module-manipulation commands Specifically, we have: - enable-module - disable-module - toggle-module These can be used to add/remove modules to be loaded or force modules to be loaded in spite of modules_blacklist. In the typical case, a user is expected to use them to recover an issue happening due to a module directive they've added to their loader.conf or because they discover that they've under-specified what to load. MFC after:1 week 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 Sat Dec 12 02:26:43 2020(r368574) +++ head/stand/lua/cli.lua Sat Dec 12 05:57:42 2020(r368575) @@ -65,6 +65,14 @@ local function parseBootArgs(argv, with_kernel) end end +local function setModule(module, loading) + if loading and config.enableModule(module) then + print(module .. " will be loaded") + elseif not loading and config.disableModule(module) then + print(module .. " will not be loaded") + end +end + -- Declares a global function cli_execute that attempts to dispatch the -- arguments passed as a lua function. This gives lua a chance to intercept -- builtin CLI commands like "boot" @@ -132,6 +140,37 @@ end cli['reload-conf'] = function() config.reload() +end + +cli["enable-module"] = function(...) + local _, argv = cli.arguments(...) + if #argv == 0 then + print("usage error: enable-module module") + return + end + + setModule(argv[1], true) +end + +cli["disable-module"] = function(...) + local _, argv = cli.arguments(...) + if #argv == 0 then + print("usage error: disable-module module") + return + end + + setModule(argv[1], false) +end + +cli["toggle-module"] = function(...) + local _, argv = cli.arguments(...) + if #argv == 0 then + print("usage error: toggle-module module") + return + end + + local module = argv[1] + setModule(module, not config.isModuleEnabled(module)) 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.8Sat Dec 12 02:26:43 2020(r368574) +++ head/stand/lua/cli.lua.8Sat Dec 12 05:57:42 2020(r368575) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 13, 2019 +.Dd December 12, 2020 .Dt CLI.LUA 8 .Os .Sh NAME @@ -77,14 +77,26 @@ This function may be invoked by a user at the loader p .Ic foo . Arguments may be passed to it as usual, space-delimited. .Ss Default Commands -As of present, the +The .Nm -module by default provides commands for -.Ic autoboot , -.Ic boot , -.Ic boot-conf , -and -.Ic reload-conf . +module provides the following default commands: +.Bl -bullet +.\"-width toggle-module -offset indent +.It +.Ic autoboot +.It +.Ic boot +.It +.Ic boot-conf +.It +.Ic reload-conf +.It +.Ic enable-module +.It +.Ic disable-module +.It +.Ic toggle-module +.El .Pp For .Ic autoboot , @@ -103,6 +115,16 @@ The command will reload the configuration from disk. This is useful if you have manually changed currdev and would like to easily reload the configuration from the new device. +.Pp +The +.Ic enable-module , +.Ic disable-module , +and +.Ic toggle-module +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. .Ss Exported Functions The following functions are exported from .Nm : Modified: head/stand/lua/config.lua == --- head/stand/lua/config.lua Sat Dec 12 02:26:43 2020(r368574) +++ head/stand/lua/config.lua Sat Dec 12 05:57:42 2020(r368575) @@ -312,7 +312,7 @@ local function loadModule(mod, silent) for k, v in pairs(mod) do if v.load ~= nil and v.load:lower() == "yes" then local module_name = v.name or k - if blacklist[module_name] ~= nil then + if not v.force and blacklist[module_name] ~= nil then if not silent then print(MSG_MODBLACKLIST:format(module_name)) end @@ -680,6 +680,45 @@ function config.loadelf() status = loadModule(modules, not config.verbose) hook.runAll("modules.loaded")