From owner-svn-src-head@freebsd.org Sat Feb 24 20:07:40 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 17278F0B88B; Sat, 24 Feb 2018 20:07:40 +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 B3DAE7460D; Sat, 24 Feb 2018 20:07:39 +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 AC64F2A33C; Sat, 24 Feb 2018 20:07:39 +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 w1OK7dOf068543; Sat, 24 Feb 2018 20:07:39 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1OK7dHU068542; Sat, 24 Feb 2018 20:07:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802242007.w1OK7dHU068542@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 24 Feb 2018 20:07:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329924 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329924 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, 24 Feb 2018 20:07:40 -0000 Author: kevans Date: Sat Feb 24 20:07:39 2018 New Revision: 329924 URL: https://svnweb.freebsd.org/changeset/base/329924 Log: lualoader: throw out nextboot's usage of standard config processing It should use the common parser, but it should not be processed like a standard file. Rewite check_nextboot to read the file in, check whether it should continue, then parse as needed. This allows us to throw the recently introduced check_and_halt callback swiftly out the window. Modified: head/stand/lua/config.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Sat Feb 24 20:00:31 2018 (r329923) +++ head/stand/lua/config.lua Sat Feb 24 20:07:39 2018 (r329924) @@ -124,19 +124,45 @@ pattern_table = { } } +local function read_file(name, silent) + local f = io.open(name) + if f == nil then + if not silent then + print("Failed to open config: '" .. name .. "'") + end + return nil + end + + local text, _ = io.read(f) + -- We might have read in the whole file, this won't be needed any more. + io.close(f) + + if text == nil then + if not silent then + print("Failed to read config: '" .. name .. "'") + end + return nil + end + return text +end + local function check_nextboot() local nextboot_file = loader.getenv("nextboot_file") if nextboot_file == nil then return end - local function check_nextboot_enabled(text) - return text:match("^nextboot_enable=\"NO\"") == nil + local text = read_file(nextboot_file, true) + if text == nil then + return end - if not config.processFile(nextboot_file, true, check_nextboot_enabled) - then - -- This only fails if it actually hit a parse error + if text:match("^nextboot_enable=\"NO\"") ~= nil then + -- We're done; nextboot is not enabled + return + end + + if not config.parse(text) then print("Failed to parse nextboot configuration: '" .. nextboot_file .. "'") end @@ -157,28 +183,6 @@ local function check_nextboot() end end -local function read_file(name, silent) - local f = io.open(name) - if f == nil then - if not silent then - print("Failed to open config: '" .. name .. "'") - end - return nil - end - - local text, _ = io.read(f) - -- We might have read in the whole file, this won't be needed any more. - io.close(f) - - if text == nil then - if not silent then - print("Failed to read config: '" .. name .. "'") - end - return nil - end - return text -end - -- Module exports -- Which variables we changed config.env_changed = {} @@ -327,7 +331,7 @@ function config.loadmod(mod, silent) return status end -function config.processFile(name, silent, check_and_halt) +function config.processFile(name, silent) if silent == nil then silent = false end @@ -335,13 +339,6 @@ function config.processFile(name, silent, check_and_ha local text = read_file(name, silent) if text == nil then return not silent - end - - if check_and_halt ~= nil then - if not check_and_halt(text) then - -- We'll just pretend that everything is fine... - return true - end end return config.parse(text)