core.lua (a2a7830eb1e68712fde0b639aec87ef678ada634) core.lua (35b0c718d312ae8067c598910886553c5b4da02a)
1--
2-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 124 unchanged lines hidden (view full) ---

133 loader.unsetenv("hw.ata.wc")
134 loader.unsetenv("hw.eisa_slots")
135 loader.unsetenv("kern.eventtimer.periodic")
136 loader.unsetenv("kern.geom.part.check_integrity")
137 end
138 core.sm = safe_mode
139end
140
1--
2-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 124 unchanged lines hidden (view full) ---

133 loader.unsetenv("hw.ata.wc")
134 loader.unsetenv("hw.eisa_slots")
135 loader.unsetenv("kern.eventtimer.periodic")
136 loader.unsetenv("kern.geom.part.check_integrity")
137 end
138 core.sm = safe_mode
139end
140
141function core.configReloaded()
142 -- Clear the kernel cache on config changes, autodetect might have
143 -- changed or if we've switched boot environments then we could have
144 -- a new kernel set.
145 core.cached_kernels = nil
146end
147
141function core.kernelList()
148function core.kernelList()
149 if core.cached_kernels ~= nil then
150 return core.cached_kernels
151 end
152
142 local k = loader.getenv("kernel")
143 local v = loader.getenv("kernels")
144 local autodetect = loader.getenv("kernels_autodetect") or ""
145
146 local kernels = {}
147 local unique = {}
148 local i = 0
149 if k ~= nil then

--- 11 unchanged lines hidden (view full) ---

161 end
162 end
163 end
164
165 -- Base whether we autodetect kernels or not on a loader.conf(5)
166 -- setting, kernels_autodetect. If it's set to 'yes', we'll add
167 -- any kernels we detect based on the criteria described.
168 if autodetect:lower() ~= "yes" then
153 local k = loader.getenv("kernel")
154 local v = loader.getenv("kernels")
155 local autodetect = loader.getenv("kernels_autodetect") or ""
156
157 local kernels = {}
158 local unique = {}
159 local i = 0
160 if k ~= nil then

--- 11 unchanged lines hidden (view full) ---

172 end
173 end
174 end
175
176 -- Base whether we autodetect kernels or not on a loader.conf(5)
177 -- setting, kernels_autodetect. If it's set to 'yes', we'll add
178 -- any kernels we detect based on the criteria described.
179 if autodetect:lower() ~= "yes" then
169 return kernels
180 core.cached_kernels = kernels
181 return core.cached_kernels
170 end
171
172 -- Automatically detect other bootable kernel directories using a
173 -- heuristic. Any directory in /boot that contains an ordinary file
174 -- named "kernel" is considered eligible.
175 for file in lfs.dir("/boot") do
176 local fname = "/boot/" .. file
177

--- 12 unchanged lines hidden (view full) ---

190 if unique[file] == nil then
191 i = i + 1
192 kernels[i] = file
193 unique[file] = true
194 end
195
196 ::continue::
197 end
182 end
183
184 -- Automatically detect other bootable kernel directories using a
185 -- heuristic. Any directory in /boot that contains an ordinary file
186 -- named "kernel" is considered eligible.
187 for file in lfs.dir("/boot") do
188 local fname = "/boot/" .. file
189

--- 12 unchanged lines hidden (view full) ---

202 if unique[file] == nil then
203 i = i + 1
204 kernels[i] = file
205 unique[file] = true
206 end
207
208 ::continue::
209 end
198 return kernels
210 core.cached_kernels = kernels
211 return core.cached_kernels
199end
200
201function core.bootenvDefault()
202 return loader.getenv("zfs_be_active")
203end
204
205function core.bootenvList()
206 local bootenv_count = tonumber(loader.getenv("bootenvs_count"))

--- 148 unchanged lines hidden ---
212end
213
214function core.bootenvDefault()
215 return loader.getenv("zfs_be_active")
216end
217
218function core.bootenvList()
219 local bootenv_count = tonumber(loader.getenv("bootenvs_count"))

--- 148 unchanged lines hidden ---