core.lua (3f4eb56bde0a50e01c3aa9783fb839919f3e48b4) core.lua (7efc058f76fa7af45860d864f4f9cd93b2c35de4)
1--
2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
3-- All rights reserved.
4--
5-- Redistribution and use in source and binary forms, with or without
6-- modification, are permitted provided that the following conditions
7-- are met:
8-- 1. Redistributions of source code must retain the above copyright

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

237 unique[file] = true
238 end
239
240 ::continue::
241 end
242 return kernels
243end
244
1--
2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
3-- All rights reserved.
4--
5-- Redistribution and use in source and binary forms, with or without
6-- modification, are permitted provided that the following conditions
7-- are met:
8-- 1. Redistributions of source code must retain the above copyright

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

237 unique[file] = true
238 end
239
240 ::continue::
241 end
242 return kernels
243end
244
245function core.bootenvDefault()
246 return loader.getenv("zfs_be_active")
247end
248
249function core.bootenvList()
250 local bootenv_count = tonumber(loader.getenv("bootenvs_count"))
251 local bootenvs = {}
252 local curenv
253 local curenv_idx = 0
254 local envcount = 0
255 local unique = {}
256
257 if bootenv_count == nil or bootenv_count <= 0 then
258 return bootenvs
259 end
260
261 -- Currently selected bootenv is always first/default
262 curenv = core.bootenvDefault()
263 if curenv ~= nil then
264 envcount = envcount + 1
265 bootenvs[envcount] = curenv
266 unique[curenv] = true
267 end
268
269 for curenv_idx = 0, bootenv_count - 1 do
270 curenv = loader.getenv("bootenvs[" .. curenv_idx .. "]")
271 if curenv ~= nil and unique[curenv] == nil then
272 envcount = envcount + 1
273 bootenvs[envcount] = curenv
274 unique[curenv] = true
275 end
276 end
277 return bootenvs
278end
279
245function core.setDefaults()
246 core.setACPI(core.getACPIPresent(true))
247 core.setSafeMode(false)
248 core.setSingleUser(false)
249 core.setVerbose(false)
250end
251
252function core.autoboot(argstr)

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

259 loader.perform(compose_loader_cmd("boot", argstr))
260end
261
262function core.isSingleUserBoot()
263 local single_user = loader.getenv("boot_single")
264 return single_user ~= nil and single_user:lower() == "yes"
265end
266
280function core.setDefaults()
281 core.setACPI(core.getACPIPresent(true))
282 core.setSafeMode(false)
283 core.setSingleUser(false)
284 core.setVerbose(false)
285end
286
287function core.autoboot(argstr)

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

294 loader.perform(compose_loader_cmd("boot", argstr))
295end
296
297function core.isSingleUserBoot()
298 local single_user = loader.getenv("boot_single")
299 return single_user ~= nil and single_user:lower() == "yes"
300end
301
302function core.isZFSBoot()
303 local c = loader.getenv("currdev")
304
305 if c ~= nil then
306 return c:match("^zfs:") ~= nil
307 end
308 return false
309end
310
267function core.isSerialBoot()
268 local c = loader.getenv("console")
269
270 if c ~= nil then
271 if c:find("comconsole") ~= nil then
272 return true
273 end
274 end

--- 61 unchanged lines hidden ---
311function core.isSerialBoot()
312 local c = loader.getenv("console")
313
314 if c ~= nil then
315 if c:find("comconsole") ~= nil then
316 return true
317 end
318 end

--- 61 unchanged lines hidden ---