Page MenuHomeFreeBSD

D55359.id.diff
No OneTemporary

D55359.id.diff

diff --git a/stand/lua/core.lua b/stand/lua/core.lua
--- a/stand/lua/core.lua
+++ b/stand/lua/core.lua
@@ -305,6 +305,15 @@
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 = {}
@@ -332,11 +341,18 @@
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
diff --git a/stand/lua/core.lua.8 b/stand/lua/core.lua.8
--- a/stand/lua/core.lua.8
+++ b/stand/lua/core.lua.8
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 29, 2025
+.Dd February 18, 2026
.Dt CORE.LUA 8
.Os
.Sh NAME
@@ -164,6 +164,17 @@
kernels will be autodetected from the current system.
.It Fn core.bootenvDefault
Returns the default boot environment, nil if unset.
+.It Fn core.bootenvFilter func
+Installs a filter
+.Fa func
+into
+.Fn core.bootenvList .
+If the
+.Fa func
+returns true, then the boot environment is retained in the list.
+Otherwise, the boot environment is hidden.
+The old filter, if any, is returned to allow the caller to compose a filter on
+top of another filter.
.It Fn core.bootenvList
Returns a table of boot environments, or an empty table.
These will be picked up using the

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 3, 11:07 PM (18 m, 58 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29130134
Default Alt Text
D55359.id.diff (1 KB)

Event Timeline