From owner-svn-src-all@freebsd.org Sat Feb 24 03:35:36 2018 Return-Path: Delivered-To: svn-src-all@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 59334F1019B; Sat, 24 Feb 2018 03:35:36 +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 07AD46A3E5; Sat, 24 Feb 2018 03:35:36 +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 021E91FF25; Sat, 24 Feb 2018 03:35:36 +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 w1O3ZZnw067557; Sat, 24 Feb 2018 03:35:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1O3ZZvr067556; Sat, 24 Feb 2018 03:35:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802240335.w1O3ZZvr067556@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 03:35:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329897 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329897 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Feb 2018 03:35:36 -0000 Author: kevans Date: Sat Feb 24 03:35:35 2018 New Revision: 329897 URL: https://svnweb.freebsd.org/changeset/base/329897 Log: lualoader: Add nextboot support config.parse now takes an extra callback that is invoked on the full text of the config file. This callback dictates where we should actually try to parse this file or not. For nextboot, we use this to halt parsing if we see 'nextboot_enable="NO"'. If we don't, parse it and write 'nextboot_enable="NO" ' to it. The same caveat as with forth still applies- writing is only supported by UFS. Modified: head/stand/lua/config.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Sat Feb 24 03:33:46 2018 (r329896) +++ head/stand/lua/config.lua Sat Feb 24 03:35:35 2018 (r329897) @@ -124,6 +124,27 @@ pattern_table = { } } +local function check_nextboot() + local nextboot_file = loader.getenv("nextboot_file") + if nextboot_file == nil then + return + end + + local function check_nextboot_disabled(text) + return not text:match("^nextboot_enable=\"NO\"") + end + + if not config.parse(nextboot_file, true, check_nextboot_disabled) then + -- This only fails if it actually hit a parse error + print("Failed to parse nextboot configuration: '" .. + nextboot_file .. "'") + end + + local nfile = io.open(nextboot_file, 'w') + io.write(nfile, "nextboot_enable=\"NO\" ") + io.close(nfile) +end + -- Module exports -- Which variables we changed config.env_changed = {} @@ -273,7 +294,9 @@ function config.loadmod(mod, silent) end -- silent runs will not return false if we fail to open the file -function config.parse(name, silent) +-- check_and_halt, if it's set, will be executed on the full text of the config +-- file. If it returns false, we are to halt immediately. +function config.parse(name, silent, check_and_halt) if silent == nil then silent = false end @@ -294,6 +317,13 @@ function config.parse(name, silent) return 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 local n = 1 local status = true @@ -438,6 +468,8 @@ function config.load(file) end end end + + check_nextboot() -- Cache the provided module_path at load time for later use config.module_path = loader.getenv("module_path")