Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Aug 2018 04:28:02 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338309 - head/stand/lua
Message-ID:  <201808250428.w7P4S2KX027420@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Sat Aug 25 04:28:02 2018
New Revision: 338309
URL: https://svnweb.freebsd.org/changeset/base/338309

Log:
  lualoader: Fix override of module_path on loader prompt
  
  Earlier changes setup a config.module_path variable that was populated upon
  reading of loader.conf(5) and used for restoring module_path to pristine
  condition if multiple kernels are attempted. This broke the ability to
  override module_path at the loader prompt in case of emergency.
  
  Approved by:	re (rgrimes)

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==============================================================================
--- head/stand/lua/config.lua	Fri Aug 24 22:48:19 2018	(r338308)
+++ head/stand/lua/config.lua	Sat Aug 25 04:28:02 2018	(r338309)
@@ -479,6 +479,21 @@ function config.loadKernel(other_kernel)
 		return nil
 	end
 
+	local function getModulePath()
+		local module_path = loader.getenv("module_path")
+		local kernel_path = loader.getenv("kernel_path")
+
+		if kernel_path == nil then
+			return module_path
+		end
+
+		-- Strip the loaded kernel path from module_path. This currently assumes
+		-- that the kernel path will be prepended to the module_path when it's
+		-- found.
+		kernel_path = escapeName(kernel_path .. ';')
+		return module_path:gsub(kernel_path, '')
+	end
+
 	local function loadBootfile()
 		local bootfile = loader.getenv("bootfile")
 
@@ -507,7 +522,7 @@ function config.loadKernel(other_kernel)
 	else
 		-- Use our cached module_path, so we don't end up with multiple
 		-- automatically added kernel paths to our final module_path
-		local module_path = config.module_path
+		local module_path = getModulePath()
 		local res
 
 		if other_kernel ~= nil then
@@ -527,6 +542,7 @@ function config.loadKernel(other_kernel)
 				if module_path ~= nil then
 					loader.setenv("module_path", v .. ";" ..
 					    module_path)
+					loader.setenv("kernel_path", v)
 				end
 				return true
 			end
@@ -563,8 +579,6 @@ function config.load(file, reloading)
 
 	checkNextboot()
 
-	-- Cache the provided module_path at load time for later use
-	config.module_path = loader.getenv("module_path")
 	local verbose = loader.getenv("verbose_loading") or "no"
 	config.verbose = verbose:lower() == "yes"
 	if not reloading then



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808250428.w7P4S2KX027420>