lualoader: Add boot environment support

This looks a little bit differently than the forth version for the time
being, just to get off the ground- rather than a paging system, it's
implemented as a simple carousel like the kernel selector.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D14436
This commit is contained in:
Kyle Evans
2018-02-21 16:50:41 +00:00
parent 94d7be6551
commit 7efc058f76
2 changed files with 113 additions and 0 deletions
+44
View File
@@ -242,6 +242,41 @@ function core.kernelList()
return kernels
end
function core.bootenvDefault()
return loader.getenv("zfs_be_active")
end
function core.bootenvList()
local bootenv_count = tonumber(loader.getenv("bootenvs_count"))
local bootenvs = {}
local curenv
local curenv_idx = 0
local envcount = 0
local unique = {}
if bootenv_count == nil or bootenv_count <= 0 then
return bootenvs
end
-- Currently selected bootenv is always first/default
curenv = core.bootenvDefault()
if curenv ~= nil then
envcount = envcount + 1
bootenvs[envcount] = curenv
unique[curenv] = true
end
for curenv_idx = 0, bootenv_count - 1 do
curenv = loader.getenv("bootenvs[" .. curenv_idx .. "]")
if curenv ~= nil and unique[curenv] == nil then
envcount = envcount + 1
bootenvs[envcount] = curenv
unique[curenv] = true
end
end
return bootenvs
end
function core.setDefaults()
core.setACPI(core.getACPIPresent(true))
core.setSafeMode(false)
@@ -264,6 +299,15 @@ function core.isSingleUserBoot()
return single_user ~= nil and single_user:lower() == "yes"
end
function core.isZFSBoot()
local c = loader.getenv("currdev")
if c ~= nil then
return c:match("^zfs:") ~= nil
end
return false
end
function core.isSerialBoot()
local c = loader.getenv("console")