aboutsummaryrefslogtreecommitdiff
path: root/stand/lua/core.lua
diff options
context:
space:
mode:
Diffstat (limited to 'stand/lua/core.lua')
-rw-r--r--stand/lua/core.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/stand/lua/core.lua b/stand/lua/core.lua
index c276f61e5904..687376cbc40f 100644
--- a/stand/lua/core.lua
+++ b/stand/lua/core.lua
@@ -314,6 +314,21 @@ function core.bootenvFilter(func)
return oldf
end
+function core.bootenvIter()
+ local envs = core.bootenvList()
+
+ if #envs ~= 0 then
+ local root = "zfs:" .. loader.getenv("zfs_be_root") .. "/"
+
+ for idx, bespec in ipairs(envs) do
+ bespec = bespec:gsub("^" .. root, "")
+ envs[idx] = bespec
+ end
+ end
+
+ return next, envs, nil
+end
+
function core.bootenvList()
local bootenv_count = tonumber(loader.getenv(bootenv_list .. "_count"))
local bootenvs = {}
@@ -567,6 +582,34 @@ function core.nextConsoleChoice()
end
end
+function core.switchBE(env)
+ -- This branch will most likely be taken by the switch-be CLI command,
+ -- not by the menu. We could do some more validation that it's a valid
+ -- BE and let the user fully specify a zfs:be/dataset to avoid the
+ -- validation, but this isn't done at the moment.
+ if not env:match("^zfs:") then
+ local root = loader.getenv("zfs_be_root")
+
+ if not root then
+ print("ZFS BE root not available -- no action taken")
+ return
+ end
+
+ if not env:match("^" .. root) then
+ env = "zfs:" .. root .. "/" .. env
+ else
+ env = "zfs:" .. env
+ end
+ end
+
+ loader.setenv("vfs.root.mountfrom", env)
+ loader.setenv("currdev", env .. ":")
+ config.reload()
+ if loader.getenv("kernelname") ~= nil then
+ loader.perform("unload")
+ end
+end
+
-- The graphical-enabled loaders have unicode drawing character support. The
-- text-only ones do not. We check the old and new bindings for term_drawrect as
-- a proxy for unicode support, which will work on older boot loaders as well