mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-24 09:13:37 +01:00
lualoader: Re-work menu skipping bits
This is motivated by a want to reduce heap usage if the menu is being skipped. Currently, the menu module must be loaded regardless of whether it's being skipped or not, which adds a cool ~50-100KB worth of memory usage. Move the menu skip logic out to core (and remove a debug print), then check in loader.lua if we should be skipping the menu and avoid loading the menu module entirely if so. This keeps our memory usage below ~115KB for a boot with the menu stripped. Also worth noting: with this change, we no longer explicitly invoke autoboot if we're skipping the menu. Instead, we let the standard loader behavior apply: try to autoboot if we need to, then drop to a loader prompt if not or if the autoboot sequence is interrupted. The only thing we still handle before dropping to the loader autoboot sequence is loadelf(), so that we can still apply any of our kernel loading behavior.
This commit is contained in:
parent
cd78f5ff20
commit
9937e97979
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330020
@ -285,6 +285,20 @@ function core.isSystem386()
|
||||
return loader.machine_arch == "i386"
|
||||
end
|
||||
|
||||
-- Is the menu skipped in the environment in which we've booted?
|
||||
function core.isMenuSkipped()
|
||||
if core.isSerialBoot() then
|
||||
return true
|
||||
end
|
||||
local c = string.lower(loader.getenv("console") or "")
|
||||
if c:match("^efi[ ;]") ~= nil or c:match("[ ;]efi[ ;]") ~= nil then
|
||||
return true
|
||||
end
|
||||
|
||||
c = string.lower(loader.getenv("beastie_disable") or "")
|
||||
return c == "yes"
|
||||
end
|
||||
|
||||
-- This may be a better candidate for a 'utility' module.
|
||||
function core.deepCopyTable(tbl)
|
||||
local new_tbl = {}
|
||||
|
@ -30,8 +30,12 @@
|
||||
--
|
||||
|
||||
require("cli")
|
||||
local core = require("core")
|
||||
local config = require("config")
|
||||
local menu = require("menu")
|
||||
local menu
|
||||
if not core.isMenuSkipped() then
|
||||
menu = require("menu")
|
||||
end
|
||||
local password = require("password")
|
||||
|
||||
local result = lfs.attributes("/boot/lua/local.lua")
|
||||
@ -42,4 +46,10 @@ end
|
||||
|
||||
config.load()
|
||||
password.check()
|
||||
menu.run()
|
||||
-- menu might be disabled
|
||||
if menu ~= nil then
|
||||
menu.run()
|
||||
else
|
||||
-- Load kernel/modules before we go
|
||||
config.loadelf()
|
||||
end
|
||||
|
@ -405,11 +405,6 @@ function menu.process(menudef, keypress)
|
||||
end
|
||||
|
||||
function menu.run()
|
||||
if menu.skip() then
|
||||
core.autoboot()
|
||||
return
|
||||
end
|
||||
|
||||
menu.draw(menu.default)
|
||||
local autoboot_key = menu.autoboot()
|
||||
|
||||
@ -420,20 +415,6 @@ function menu.run()
|
||||
print("Exiting menu!")
|
||||
end
|
||||
|
||||
function menu.skip()
|
||||
if core.isSerialBoot() then
|
||||
return true
|
||||
end
|
||||
local c = string.lower(loader.getenv("console") or "")
|
||||
if c:match("^efi[ ;]") ~= nil or c:match("[ ;]efi[ ;]") ~= nil then
|
||||
return true
|
||||
end
|
||||
|
||||
c = string.lower(loader.getenv("beastie_disable") or "")
|
||||
print("beastie_disable", c)
|
||||
return c == "yes"
|
||||
end
|
||||
|
||||
function menu.autoboot()
|
||||
local ab = loader.getenv("autoboot_delay")
|
||||
if ab ~= nil and ab:lower() == "no" then
|
||||
|
Loading…
Reference in New Issue
Block a user