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.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/stand/lua/core.lua b/stand/lua/core.lua
index ccd8213a718d..4091f446e1f1 100644
--- a/stand/lua/core.lua
+++ b/stand/lua/core.lua
@@ -303,6 +303,15 @@ function core.bootenvDefault()
return loader.getenv("zfs_be_active")
end
+function core.bootenvFilter(func)
+ local oldf = core.bootenv_filter
+
+ -- Filter contract: returns true if the BE should be kept, false if it
+ -- should be hidden.
+ core.bootenv_filter = func
+ return oldf
+end
+
function core.bootenvList()
local bootenv_count = tonumber(loader.getenv(bootenv_list .. "_count"))
local bootenvs = {}
@@ -330,11 +339,18 @@ function core.bootenvList()
for curenv_idx = 0, bootenv_count - 1 do
curenv = loader.getenv(bootenv_list .. "[" .. curenv_idx .. "]")
if curenv ~= nil and unique[curenv] == nil then
- envcount = envcount + 1
- bootenvs[envcount] = curenv
unique[curenv] = true
+
+ -- If we have a filter installed (by a local module), we
+ -- give it a chance to veto the BE.
+ if not core.bootenv_filter or
+ core.bootenv_filter(curenv) then
+ envcount = envcount + 1
+ bootenvs[envcount] = curenv
+ end
end
end
+
return bootenvs
end