Date: Sun, 18 Feb 2018 01:16:37 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329501 - head/stand/lua Message-ID: <201802180116.w1I1Gbq1087540@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Sun Feb 18 01:16:37 2018 New Revision: 329501 URL: https://svnweb.freebsd.org/changeset/base/329501 Log: lua loader: Auto detect eligible list of kernels to boot Reviewed by: imp, kevans Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14419 Modified: head/stand/lua/core.lua Modified: head/stand/lua/core.lua ============================================================================== --- head/stand/lua/core.lua Sun Feb 18 01:15:25 2018 (r329500) +++ head/stand/lua/core.lua Sun Feb 18 01:16:37 2018 (r329501) @@ -127,17 +127,47 @@ function core.kernelList() local v = loader.getenv("kernels") or ""; local kernels = {}; + local unique = {}; local i = 0; if (k ~= nil) then i = i + 1; kernels[i] = k; + unique[k] = true; end for n in v:gmatch("([^; ]+)[; ]?") do - if (n ~= k) then + if (unique[n] == nil) then i = i + 1; kernels[i] = n; + unique[n] = true; end + end + + -- Automatically detect other bootable kernel directories using a + -- heuristic. Any directory in /boot that contains an ordinary file + -- named "kernel" is considered eligible. + for file in lfs.dir("/boot") do + local fname = "/boot/" .. file; + + if (file == "." or file == "..") then + goto continue; + end + + if (lfs.attributes(fname, "mode") ~= "directory") then + goto continue; + end + + if (lfs.attributes(fname .. "/kernel", "mode") ~= "file") then + goto continue; + end + + if (unique[file] == nil) then + i = i + 1; + kernels[i] = file; + unique[file] = true; + end + + ::continue:: end return kernels; end
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802180116.w1I1Gbq1087540>