From owner-svn-src-head@freebsd.org Sat Feb 17 05:02:39 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 18ED3F0EB43; Sat, 17 Feb 2018 05:02:39 +0000 (UTC) (envelope-from kevans@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 E1E1F86C92; Sat, 17 Feb 2018 05:02:38 +0000 (UTC) (envelope-from kevans@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 C337118243; Sat, 17 Feb 2018 05:02:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1H52c7c072897; Sat, 17 Feb 2018 05:02:38 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1H52cQf072896; Sat, 17 Feb 2018 05:02:38 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802170502.w1H52cQf072896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 17 Feb 2018 05:02:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329432 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329432 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: Sat, 17 Feb 2018 05:02:39 -0000 Author: kevans Date: Sat Feb 17 05:02:38 2018 New Revision: 329432 URL: https://svnweb.freebsd.org/changeset/base/329432 Log: stand/lua: Try to load alternate kernels as directories first This is the procedure that config.loadkernel tries to go through, but reloading kernel config didn't use this function. Amend config.loadkernel to take an optional other_kernel. While here, be a little more verbose ("Trying to load kernel") so that it's easy to follow where we've gone wrong. Modified: head/stand/lua/config.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Sat Feb 17 04:46:06 2018 (r329431) +++ head/stand/lua/config.lua Sat Feb 17 05:02:38 2018 (r329432) @@ -253,9 +253,11 @@ function config.parse(name, silent) return status; end -function config.loadkernel() +-- other_kernel is optionally the name of a kernel to load, if not the default +-- or autoloaded default from the module_path +function config.loadkernel(other_kernel) local flags = loader.getenv("kernel_options") or ""; - local kernel = loader.getenv("kernel"); + local kernel = other_kernel or loader.getenv("kernel"); local try_load = function (names) for name in names:gmatch("([^;]+)%s*;?") do @@ -265,7 +267,7 @@ function config.loadkernel() end end return nil; - end; + end local load_bootfile = function() local bootfile = loader.getenv("bootfile"); @@ -294,6 +296,9 @@ function config.loadkernel() local module_path = loader.getenv("module_path"); local res = nil; + if other_kern ~= nil then + kernel = other_kern; + end -- first try load kernel with module_path = /boot/${kernel} -- then try load with module_path=${kernel} local paths = {"/boot/"..kernel, kernel}; @@ -355,22 +360,23 @@ function config.load(file) end function config.reload(kernel) - local res = 1; + local kernel_loaded = false; -- unload all modules print("Unloading modules..."); loader.perform("unload"); - if kernel ~= nil then - res = loader.perform("load "..kernel); - if res == 0 then + if (kernel ~= nil) then + print("Trying to load '" .. kernel .. "'") + kernel_loaded = config.loadkernel(kernel); + if (kernel_loaded) then print("Kernel '"..kernel.."' loaded!"); end end -- failed to load kernel or it is nil -- then load default - if res == 1 then + if (not kernel_loaded) then print("Loading default kernel..."); config.loadkernel(); end