From owner-svn-src-head@freebsd.org Sun Feb 18 01:16:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61551F2504F; Sun, 18 Feb 2018 01:16:38 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1443A78DE6; Sun, 18 Feb 2018 01:16:38 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0F3AF249A5; Sun, 18 Feb 2018 01:16:38 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1I1GbDn087541; Sun, 18 Feb 2018 01:16:37 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1I1Gbq1087540; Sun, 18 Feb 2018 01:16:37 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201802180116.w1I1Gbq1087540@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sun, 18 Feb 2018 01:16:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329501 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329501 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Feb 2018 01:16:38 -0000 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