lualoader: Clean up naming conventions a little bit

We mostly use camel case for function names, but some local functions got
mixed in using internal underscores. Doubles down on camel case.
This commit is contained in:
Kyle Evans 2018-02-24 20:21:21 +00:00
parent 9b7ae69179
commit 322a2dddba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329927
6 changed files with 31 additions and 31 deletions

View File

@ -38,7 +38,7 @@ local cli = {}
-- Defaults to nil and "" respectively. -- Defaults to nil and "" respectively.
-- This will also parse arguments to autoboot, but the with_kernel argument -- This will also parse arguments to autoboot, but the with_kernel argument
-- will need to be explicitly overwritten to false -- will need to be explicitly overwritten to false
local function parse_boot_args(argv, with_kernel) local function parseBootArgs(argv, with_kernel)
if with_kernel == nil then if with_kernel == nil then
with_kernel = true with_kernel = true
end end
@ -95,17 +95,17 @@ end
function cli.boot(...) function cli.boot(...)
local _, argv = cli.arguments(...) local _, argv = cli.arguments(...)
local kernel, argstr = parse_boot_args(argv) local kernel, argstr = parseBootArgs(argv)
if kernel ~= nil then if kernel ~= nil then
loader.perform("unload") loader.perform("unload")
config.selectkernel(kernel) config.selectKernel(kernel)
end end
core.boot(argstr) core.boot(argstr)
end end
function cli.autoboot(...) function cli.autoboot(...)
local _, argv = cli.arguments(...) local _, argv = cli.arguments(...)
local argstr = parse_boot_args(argv, false) local argstr = parseBootArgs(argv, false)
core.autoboot(argstr) core.autoboot(argstr)
end end

View File

@ -124,7 +124,7 @@ pattern_table = {
} }
} }
local function read_file(name, silent) local function readFile(name, silent)
local f = io.open(name) local f = io.open(name)
if f == nil then if f == nil then
if not silent then if not silent then
@ -146,13 +146,13 @@ local function read_file(name, silent)
return text return text
end end
local function check_nextboot() local function checkNextboot()
local nextboot_file = loader.getenv("nextboot_file") local nextboot_file = loader.getenv("nextboot_file")
if nextboot_file == nil then if nextboot_file == nil then
return return
end end
local text = read_file(nextboot_file, true) local text = readFile(nextboot_file, true)
if text == nil then if text == nil then
return return
end end
@ -169,7 +169,7 @@ local function check_nextboot()
-- Attempt to rewrite the first line and only the first line of the -- Attempt to rewrite the first line and only the first line of the
-- nextboot_file. We overwrite it with nextboot_enable="NO", then -- nextboot_file. We overwrite it with nextboot_enable="NO", then
-- check for that on load. See: check_nextboot_enabled -- check for that on load. See: checkNextboot_enabled
-- It's worth noting that this won't work on every filesystem, so we -- It's worth noting that this won't work on every filesystem, so we
-- won't do anything notable if we have any errors in this process. -- won't do anything notable if we have any errors in this process.
local nfile = io.open(nextboot_file, 'w') local nfile = io.open(nextboot_file, 'w')
@ -336,7 +336,7 @@ function config.processFile(name, silent)
silent = false silent = false
end end
local text = read_file(name, silent) local text = readFile(name, silent)
if text == nil then if text == nil then
return not silent return not silent
end end
@ -386,11 +386,11 @@ end
-- other_kernel is optionally the name of a kernel to load, if not the default -- other_kernel is optionally the name of a kernel to load, if not the default
-- or autoloaded default from the module_path -- or autoloaded default from the module_path
function config.loadkernel(other_kernel) function config.loadKernel(other_kernel)
local flags = loader.getenv("kernel_options") or "" local flags = loader.getenv("kernel_options") or ""
local kernel = other_kernel or loader.getenv("kernel") local kernel = other_kernel or loader.getenv("kernel")
local function try_load(names) local function tryLoad(names)
for name in names:gmatch("([^;]+)%s*;?") do for name in names:gmatch("([^;]+)%s*;?") do
local r = loader.perform("load " .. flags .. local r = loader.perform("load " .. flags ..
" " .. name) " " .. name)
@ -401,7 +401,7 @@ function config.loadkernel(other_kernel)
return nil return nil
end end
local function load_bootfile() local function loadBootfile()
local bootfile = loader.getenv("bootfile") local bootfile = loader.getenv("bootfile")
-- append default kernel name -- append default kernel name
@ -411,12 +411,12 @@ function config.loadkernel(other_kernel)
bootfile = bootfile .. ";kernel" bootfile = bootfile .. ";kernel"
end end
return try_load(bootfile) return tryLoad(bootfile)
end end
-- kernel not set, try load from default module_path -- kernel not set, try load from default module_path
if kernel == nil then if kernel == nil then
local res = load_bootfile() local res = loadBootfile()
if res ~= nil then if res ~= nil then
-- Default kernel is loaded -- Default kernel is loaded
@ -441,7 +441,7 @@ function config.loadkernel(other_kernel)
for _, v in pairs(paths) do for _, v in pairs(paths) do
loader.setenv("module_path", v) loader.setenv("module_path", v)
res = load_bootfile() res = loadBootfile()
-- succeeded, add path to module_path -- succeeded, add path to module_path
if res ~= nil then if res ~= nil then
@ -456,7 +456,7 @@ function config.loadkernel(other_kernel)
-- failed to load with ${kernel} as a directory -- failed to load with ${kernel} as a directory
-- try as a file -- try as a file
res = try_load(kernel) res = tryLoad(kernel)
if res ~= nil then if res ~= nil then
config.kernel_loaded = kernel config.kernel_loaded = kernel
return true return true
@ -467,7 +467,7 @@ function config.loadkernel(other_kernel)
end end
end end
function config.selectkernel(kernel) function config.selectKernel(kernel)
config.kernel_selected = kernel config.kernel_selected = kernel
end end
@ -493,7 +493,7 @@ function config.load(file)
end end
end end
check_nextboot() checkNextboot()
-- Cache the provided module_path at load time for later use -- Cache the provided module_path at load time for later use
config.module_path = loader.getenv("module_path") config.module_path = loader.getenv("module_path")
@ -511,7 +511,7 @@ function config.loadelf()
local loaded local loaded
print("Loading kernel...") print("Loading kernel...")
loaded = config.loadkernel(kernel) loaded = config.loadKernel(kernel)
if not loaded then if not loaded then
print("Failed to load any kernel") print("Failed to load any kernel")

View File

@ -33,7 +33,7 @@ local config = require("config")
local core = {} local core = {}
local function compose_loader_cmd(cmd_name, argstr) local function composeLoaderCmd(cmd_name, argstr)
if argstr ~= nil then if argstr ~= nil then
cmd_name = cmd_name .. " " .. argstr cmd_name = cmd_name .. " " .. argstr
end end
@ -238,12 +238,12 @@ end
function core.autoboot(argstr) function core.autoboot(argstr)
config.loadelf() config.loadelf()
loader.perform(compose_loader_cmd("autoboot", argstr)) loader.perform(composeLoaderCmd("autoboot", argstr))
end end
function core.boot(argstr) function core.boot(argstr)
config.loadelf() config.loadelf()
loader.perform(compose_loader_cmd("boot", argstr)) loader.perform(composeLoaderCmd("boot", argstr))
end end
function core.isSingleUserBoot() function core.isSingleUserBoot()

View File

@ -45,7 +45,7 @@ local orb
local none local none
local none_shifted = false local none_shifted = false
local function menu_entry_name(drawing_menu, entry) local function menuEntryName(drawing_menu, entry)
local name_handler = drawer.menu_name_handlers[entry.entry_type] local name_handler = drawer.menu_name_handlers[entry.entry_type]
if name_handler ~= nil then if name_handler ~= nil then
@ -57,7 +57,7 @@ local function menu_entry_name(drawing_menu, entry)
return entry.name return entry.name
end end
local function shift_brand_text(shift) local function shiftBrandText(shift)
drawer.brand_position.x = drawer.brand_position.x + shift.x drawer.brand_position.x = drawer.brand_position.x + shift.x
drawer.brand_position.y = drawer.brand_position.y + shift.y drawer.brand_position.y = drawer.brand_position.y + shift.y
drawer.menu_position.x = drawer.menu_position.x + shift.x drawer.menu_position.x = drawer.menu_position.x + shift.x
@ -288,7 +288,7 @@ function drawer.drawmenu(m)
entry_num = entry_num + 1 entry_num = entry_num + 1
screen.setcursor(x, y + effective_line_num) screen.setcursor(x, y + effective_line_num)
print(entry_num .. ". " .. menu_entry_name(m, e)) print(entry_num .. ". " .. menuEntryName(m, e))
-- fill the alias table -- fill the alias table
alias_table[tostring(entry_num)] = e alias_table[tostring(entry_num)] = e
@ -299,7 +299,7 @@ function drawer.drawmenu(m)
end end
else else
screen.setcursor(x, y + effective_line_num) screen.setcursor(x, y + effective_line_num)
print(menu_entry_name(m, e)) print(menuEntryName(m, e))
end end
::continue:: ::continue::
end end
@ -379,7 +379,7 @@ function drawer.drawlogo()
if logodef ~= nil and logodef.graphic == none then if logodef ~= nil and logodef.graphic == none then
-- centre brand and text if no logo -- centre brand and text if no logo
if not none_shifted then if not none_shifted then
shift_brand_text(logodef.shift) shiftBrandText(logodef.shift)
none_shifted = true none_shifted = true
end end
elseif logodef == nil or logodef.graphic == nil or elseif logodef == nil or logodef.graphic == nil or

View File

@ -315,7 +315,7 @@ menu.welcome = {
#all_choices .. ")" #all_choices .. ")"
end, end,
func = function(_, choice, _) func = function(_, choice, _)
config.selectkernel(choice) config.selectKernel(choice)
end, end,
alias = {"k", "K"} alias = {"k", "K"}
}, },

View File

@ -65,7 +65,7 @@ function password.check()
screen.clear() screen.clear()
screen.defcursor() screen.defcursor()
-- pwd is optionally supplied if we want to check it -- pwd is optionally supplied if we want to check it
local function do_prompt(prompt, pwd) local function doPrompt(prompt, pwd)
while true do while true do
loader.printc(prompt) loader.printc(prompt)
local read_pwd = password.read() local read_pwd = password.read()
@ -82,7 +82,7 @@ function password.check()
if pwd == nil then if pwd == nil then
return return
end end
do_prompt(prompt, pwd) doPrompt(prompt, pwd)
end end
local boot_pwd = loader.getenv("bootlock_password") local boot_pwd = loader.getenv("bootlock_password")
@ -90,7 +90,7 @@ function password.check()
local geli_prompt = loader.getenv("geom_eli_passphrase_prompt") local geli_prompt = loader.getenv("geom_eli_passphrase_prompt")
if geli_prompt ~= nil and geli_prompt:lower() == "yes" then if geli_prompt ~= nil and geli_prompt:lower() == "yes" then
local passphrase = do_prompt("GELI Passphrase: ") local passphrase = doPrompt("GELI Passphrase: ")
loader.setenv("kern.geom.eli.passphrase", passphrase) loader.setenv("kern.geom.eli.passphrase", passphrase)
end end