From owner-svn-src-head@freebsd.org Sat Jun 9 17:16:14 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 27648101184F; Sat, 9 Jun 2018 17:16:14 +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 9F9F57B881; Sat, 9 Jun 2018 15:10:40 +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 80CF21F72D; Sat, 9 Jun 2018 15:10:40 +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 w59FAe2b036769; Sat, 9 Jun 2018 15:10:40 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w59FAdOT036763; Sat, 9 Jun 2018 15:10:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201806091510.w59FAdOT036763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 9 Jun 2018 15:10:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334882 - in head/stand: common efi/loader i386/libi386 userboot/userboot X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head/stand: common efi/loader i386/libi386 userboot/userboot X-SVN-Commit-Revision: 334882 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.26 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, 09 Jun 2018 17:16:14 -0000 Author: kevans Date: Sat Jun 9 15:10:39 2018 New Revision: 334882 URL: https://svnweb.freebsd.org/changeset/base/334882 Log: stand: Consolidate checking for boot flags driven by environment vars e.g. boot_mute, boot_single, boot_verbose, and friends; we checked for these in multiple places, consolidate into common/ and allow a setting of "NO" for any of these to turn them off. This allows systems with multiple loader.conf(5) or loader.conf(5) overlay systems to easily turn off variables in later processed files by setting it to NO. Reported by: Nick Wolff @ iXsystems Reviewed by: imp Modified: head/stand/common/boot.c head/stand/common/bootstrap.h head/stand/common/metadata.c head/stand/efi/loader/bootinfo.c head/stand/i386/libi386/bootinfo.c head/stand/userboot/userboot/bootinfo.c Modified: head/stand/common/boot.c ============================================================================== --- head/stand/common/boot.c Sat Jun 9 14:50:38 2018 (r334881) +++ head/stand/common/boot.c Sat Jun 9 15:10:39 2018 (r334882) @@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$"); */ #include +#include +#include #include #include "bootstrap.h" @@ -156,6 +158,20 @@ autoboot_maybe() cp = getenv("autoboot_delay"); if ((autoboot_tried == 0) && ((cp == NULL) || strcasecmp(cp, "NO"))) autoboot(-1, NULL); /* try to boot automatically */ +} + +int +bootenv_flags() +{ + int i, howto; + char *val; + + for (howto = 0, i = 0; howto_names[i].ev != NULL; i++) { + val = getenv(howto_names[i].ev); + if (val != NULL && strcasecmp(val, "no") != 0) + howto |= howto_names[i].mask; + } + return (howto); } static int Modified: head/stand/common/bootstrap.h ============================================================================== --- head/stand/common/bootstrap.h Sat Jun 9 14:50:38 2018 (r334881) +++ head/stand/common/bootstrap.h Sat Jun 9 15:10:39 2018 (r334882) @@ -63,6 +63,7 @@ int parse(int *argc, char ***argv, const char *str); /* boot.c */ void autoboot_maybe(void); int getrootmount(char *rootdev); +int bootenv_flags(void); /* misc.c */ char *unargv(int argc, char *argv[]); Modified: head/stand/common/metadata.c ============================================================================== --- head/stand/common/metadata.c Sat Jun 9 14:50:38 2018 (r334881) +++ head/stand/common/metadata.c Sat Jun 9 15:10:39 2018 (r334882) @@ -31,9 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include -#include #if defined(LOADER_FDT_SUPPORT) #include #endif @@ -100,7 +98,6 @@ md_getboothowto(char *kargs) char *cp; int howto; int active; - int i; /* Parse kargs */ howto = 0; @@ -153,10 +150,7 @@ md_getboothowto(char *kargs) } } - /* get equivalents from the environment */ - for (i = 0; howto_names[i].ev != NULL; i++) - if (getenv(howto_names[i].ev) != NULL) - howto |= howto_names[i].mask; + howto |= bootenv_flags(); #if defined(__sparc64__) if (md_bootserial() != -1) howto |= RB_SERIAL; Modified: head/stand/efi/loader/bootinfo.c ============================================================================== --- head/stand/efi/loader/bootinfo.c Sat Jun 9 14:50:38 2018 (r334881) +++ head/stand/efi/loader/bootinfo.c Sat Jun 9 15:10:39 2018 (r334882) @@ -32,9 +32,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include +#include #include #include #include @@ -72,15 +71,9 @@ bi_getboothowto(char *kargs) const char *sw; char *opts; char *console; - int howto, i; + int howto; - howto = 0; - - /* Get the boot options from the environment first. */ - for (i = 0; howto_names[i].ev != NULL; i++) { - if (getenv(howto_names[i].ev) != NULL) - howto |= howto_names[i].mask; - } + howto = bootenv_flags(); console = getenv("console"); if (console != NULL) { Modified: head/stand/i386/libi386/bootinfo.c ============================================================================== --- head/stand/i386/libi386/bootinfo.c Sat Jun 9 14:50:38 2018 (r334881) +++ head/stand/i386/libi386/bootinfo.c Sat Jun 9 15:10:39 2018 (r334882) @@ -43,7 +43,6 @@ bi_getboothowto(char *kargs) char *curpos, *next, *string; int howto; int active; - int i; int vidconsole; /* Parse kargs */ @@ -96,10 +95,7 @@ bi_getboothowto(char *kargs) cp++; } } - /* get equivalents from the environment */ - for (i = 0; howto_names[i].ev != NULL; i++) - if (getenv(howto_names[i].ev) != NULL) - howto |= howto_names[i].mask; + howto |= bootenv_flags(); /* Enable selected consoles */ string = next = strdup(getenv("console")); Modified: head/stand/userboot/userboot/bootinfo.c ============================================================================== --- head/stand/userboot/userboot/bootinfo.c Sat Jun 9 14:50:38 2018 (r334881) +++ head/stand/userboot/userboot/bootinfo.c Sat Jun 9 15:10:39 2018 (r334882) @@ -43,7 +43,6 @@ bi_getboothowto(char *kargs) char *curpos, *next, *string; int howto; int active; - int i; int vidconsole; /* Parse kargs */ @@ -96,10 +95,8 @@ bi_getboothowto(char *kargs) cp++; } } - /* get equivalents from the environment */ - for (i = 0; howto_names[i].ev != NULL; i++) - if (getenv(howto_names[i].ev) != NULL) - howto |= howto_names[i].mask; + + howto |= bootenv_flags(); /* Enable selected consoles */ string = next = strdup(getenv("console"));