Date: Tue, 20 Feb 2018 21:32:36 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329673 - head/stand/lua Message-ID: <201802202132.w1KLWaYY088452@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Tue Feb 20 21:32:36 2018 New Revision: 329673 URL: https://svnweb.freebsd.org/changeset/base/329673 Log: lualoader: Intercept boot cli command This should be functional and roughly equivalent to the Forth version. Stop doing a loadelf() on menu exit now that we can DTRT with boot invocations. autoboot interception will follow not long after. Modified: head/stand/lua/core.lua head/stand/lua/menu.lua Modified: head/stand/lua/core.lua ============================================================================== --- head/stand/lua/core.lua Tue Feb 20 21:27:17 2018 (r329672) +++ head/stand/lua/core.lua Tue Feb 20 21:32:36 2018 (r329673) @@ -37,6 +37,38 @@ local compose_loader_cmd = function(cmd_name, argstr) return cmd_name; end +-- Parses arguments to boot and returns two values: kernel_name, argstr +-- Defaults to nil and "" respectively. +local parse_boot_args = function(argv) + if (#argv == 0) then + return nil, ""; + end + local kernel_name; + local argstr = ""; + + for k, v in ipairs(argv) do + if (v:sub(1,1) ~= "-") then + kernel_name = v; + else + argstr = argstr .. " " .. v; + end + end + return kernel_name, argstr; +end + +-- Globals +function boot(...) + local argv = {...}; + local cmd_name = ""; + cmd_name, argv = core.popFrontTable(argv); + local kernel, argstr = parse_boot_args(argv); + if (kernel ~= nil) then + loader.perform("unload"); + config.selectkernel(kernel); + end + core.boot(argstr); +end + -- Module exports -- Commonly appearing constants core.KEY_BACKSPACE = 8; Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Tue Feb 20 21:27:17 2018 (r329672) +++ head/stand/lua/menu.lua Tue Feb 20 21:32:36 2018 (r329673) @@ -390,7 +390,6 @@ function menu.run(m) if (m == menu.welcome) then screen.defcursor(); print("Exiting menu!"); - config.loadelf(); return false; end
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802202132.w1KLWaYY088452>