svn commit: r334882 - in head/stand: common efi/loader i386/libi386 userboot/userboot
Kyle Evans
kevans at FreeBSD.org
Sat Jun 9 17:16:14 UTC 2018
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 <stand.h>
+#include <sys/reboot.h>
+#include <sys/boot.h>
#include <string.h>
#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 <stand.h>
#include <sys/param.h>
-#include <sys/reboot.h>
#include <sys/linker.h>
-#include <sys/boot.h>
#if defined(LOADER_FDT_SUPPORT)
#include <fdt_platform.h>
#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 <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: 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"));
More information about the svn-src-head
mailing list