Changeset View
Changeset View
Standalone View
Standalone View
stand/lua/core.lua
Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | function core.kernelList() | ||||
if autodetect:lower() ~= "yes" then | if autodetect:lower() ~= "yes" then | ||||
core.cached_kernels = kernels | core.cached_kernels = kernels | ||||
return core.cached_kernels | return core.cached_kernels | ||||
end | end | ||||
-- Automatically detect other bootable kernel directories using a | -- Automatically detect other bootable kernel directories using a | ||||
-- heuristic. Any directory in /boot that contains an ordinary file | -- heuristic. Any directory in /boot that contains an ordinary file | ||||
-- named "kernel" is considered eligible. | -- named "kernel" is considered eligible. | ||||
for file in lfs.dir("/boot") do | for file, ftype in lfs.dir("/boot") do | ||||
local fname = "/boot/" .. file | local fname = "/boot/" .. file | ||||
if file == "." or file == ".." then | if file == "." or file == ".." then | ||||
goto continue | goto continue | ||||
end | end | ||||
if lfs.attributes(fname, "mode") ~= "directory" then | if ftype then | ||||
if ftype ~= lfs.DT_DIR then | |||||
goto continue | |||||
end | |||||
elseif lfs.attributes(fname, "mode") ~= "directory" then | |||||
goto continue | goto continue | ||||
cem: This is an unfortunate shortcoming of the lfs API we copied from Lua. Our direntries have… | |||||
Done Inline ActionsGood point. I think this would be easy enough to bolt on to lfs in a way that isn't egregiously incompatible. We could switch this to using the iteration protocol manually (it's only a little uglier) and add a method to the iterator's metatable to grab it. kevans: Good point. I think this would be easy enough to bolt on to lfs in a way that isn't egregiously… | |||||
end | end | ||||
if lfs.attributes(fname .. "/kernel", "mode") ~= "file" then | if lfs.attributes(fname .. "/kernel", "mode") ~= "file" then | ||||
goto continue | goto continue | ||||
end | end | ||||
if unique[file] == nil then | if unique[file] == nil then | ||||
i = i + 1 | i = i + 1 | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |
This is an unfortunate shortcoming of the lfs API we copied from Lua. Our direntries have d_type == DT_DIR and we shouldn't need the extra stat to determine directory or not. One way to speed this up without loss of functionality would be to pass that information through to Lua.