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
This commit is contained in:
parent
4a0f8b339e
commit
593e2c6ece
@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/boot.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bootstrap.h"
|
||||
@ -158,6 +160,20 @@ autoboot_maybe()
|
||||
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
|
||||
autoboot(int timeout, char *prompt)
|
||||
{
|
||||
|
@ -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[]);
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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"));
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user