Date: Thu, 28 Jun 2018 01:32:38 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335755 - in stable/11/stand: common efi/loader i386/libi386 userboot/userboot Message-ID: <201806280132.w5S1WcXR041397@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Thu Jun 28 01:32:37 2018 New Revision: 335755 URL: https://svnweb.freebsd.org/changeset/base/335755 Log: MFC r334882, r334884-r334885: loader(8) boot flag <-> environment fixes r334882: 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 r334884: stand: Fix build after r334882 Not sure how this was not caught in Universe. r334885: stand: One more trivial consolidation (setting environment from howto) Modified: stable/11/stand/common/boot.c stable/11/stand/common/bootstrap.h stable/11/stand/common/metadata.c stable/11/stand/efi/loader/bootinfo.c stable/11/stand/efi/loader/main.c stable/11/stand/i386/libi386/bootinfo.c stable/11/stand/userboot/userboot/bootinfo.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/common/boot.c ============================================================================== --- stable/11/stand/common/boot.c Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/common/boot.c Thu Jun 28 01:32:37 2018 (r335755) @@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$"); */ #include <stand.h> +#include <sys/reboot.h> +#include <sys/boot.h> #include <string.h> #include "bootstrap.h" @@ -156,6 +158,30 @@ 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); +} + +void +bootenv_set(int howto) +{ + int i; + + for (i = 0; howto_names[i].ev != NULL; i++) + if (howto & howto_names[i].mask) + setenv(howto_names[i].ev, "YES", 1); } static int Modified: stable/11/stand/common/bootstrap.h ============================================================================== --- stable/11/stand/common/bootstrap.h Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/common/bootstrap.h Thu Jun 28 01:32:37 2018 (r335755) @@ -63,6 +63,8 @@ int parse(int *argc, char ***argv, const char *str); /* boot.c */ void autoboot_maybe(void); int getrootmount(char *rootdev); +int bootenv_flags(void); +void bootenv_set(int); /* misc.c */ char *unargv(int argc, char *argv[]); Modified: stable/11/stand/common/metadata.c ============================================================================== --- stable/11/stand/common/metadata.c Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/common/metadata.c Thu Jun 28 01:32:37 2018 (r335755) @@ -31,9 +31,8 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <sys/param.h> -#include <sys/reboot.h> #include <sys/linker.h> -#include <sys/boot.h> +#include <sys/reboot.h> #if defined(LOADER_FDT_SUPPORT) #include <fdt_platform.h> #endif @@ -100,7 +99,6 @@ md_getboothowto(char *kargs) char *cp; int howto; int active; - int i; /* Parse kargs */ howto = 0; @@ -153,10 +151,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: stable/11/stand/efi/loader/bootinfo.c ============================================================================== --- stable/11/stand/efi/loader/bootinfo.c Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/efi/loader/bootinfo.c Thu Jun 28 01:32:37 2018 (r335755) @@ -32,9 +32,8 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> #include <sys/param.h> -#include <sys/reboot.h> #include <sys/linker.h> -#include <sys/boot.h> +#include <sys/reboot.h> #include <machine/cpufunc.h> #include <machine/elf.h> #include <machine/metadata.h> @@ -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: stable/11/stand/efi/loader/main.c ============================================================================== --- stable/11/stand/efi/loader/main.c Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/efi/loader/main.c Thu Jun 28 01:32:37 2018 (r335755) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include <sys/disk.h> #include <sys/param.h> #include <sys/reboot.h> -#include <sys/boot.h> #include <stdint.h> #include <stand.h> #include <string.h> @@ -549,9 +548,8 @@ main(int argc, CHAR16 *argv[]) } } } - for (i = 0; howto_names[i].ev != NULL; i++) - if (howto & howto_names[i].mask) - setenv(howto_names[i].ev, "YES", 1); + + bootenv_set(howto); /* * XXX we need fallback to this stuff after looking at the ConIn, ConOut and ConErr variables Modified: stable/11/stand/i386/libi386/bootinfo.c ============================================================================== --- stable/11/stand/i386/libi386/bootinfo.c Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/i386/libi386/bootinfo.c Thu Jun 28 01:32:37 2018 (r335755) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/reboot.h> #include <sys/linker.h> -#include <sys/boot.h> #include "bootstrap.h" #include "libi386.h" #include "btxv86.h" @@ -43,7 +42,6 @@ bi_getboothowto(char *kargs) char *curpos, *next, *string; int howto; int active; - int i; int vidconsole; /* Parse kargs */ @@ -96,10 +94,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")); @@ -134,11 +129,8 @@ bi_getboothowto(char *kargs) void bi_setboothowto(int howto) { - int i; - for (i = 0; howto_names[i].ev != NULL; i++) - if (howto & howto_names[i].mask) - setenv(howto_names[i].ev, "YES", 1); + bootenv_set(howto); } /* Modified: stable/11/stand/userboot/userboot/bootinfo.c ============================================================================== --- stable/11/stand/userboot/userboot/bootinfo.c Thu Jun 28 01:30:03 2018 (r335754) +++ stable/11/stand/userboot/userboot/bootinfo.c Thu Jun 28 01:32:37 2018 (r335755) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/reboot.h> #include <sys/linker.h> -#include <sys/boot.h> #include "bootstrap.h" #include "libuserboot.h" @@ -43,7 +42,6 @@ bi_getboothowto(char *kargs) char *curpos, *next, *string; int howto; int active; - int i; int vidconsole; /* Parse kargs */ @@ -96,11 +94,9 @@ 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")); vidconsole = 0; @@ -134,11 +130,8 @@ bi_getboothowto(char *kargs) void bi_setboothowto(int howto) { - int i; - for (i = 0; howto_names[i].ev != NULL; i++) - if (howto & howto_names[i].mask) - setenv(howto_names[i].ev, "YES", 1); + bootenv_set(howto); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806280132.w5S1WcXR041397>