diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2018-07-05 16:30:32 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2018-07-05 16:30:32 +0000 |
commit | 39d44f7f15cf28df572028f198bc51ce2de510a5 (patch) | |
tree | fc6977e2809819dd1d3823638e209fb08f4b0b18 /usr.sbin/config | |
parent | e28687347fa065c61559d62ef1f006772956279c (diff) | |
download | src-test2-39d44f7f15cf28df572028f198bc51ce2de510a5.tar.gz src-test2-39d44f7f15cf28df572028f198bc51ce2de510a5.zip |
kern_environment: use any provided environments, evict hintmode/envmode
At the moment, hintmode and envmode are used to indicate whether static
hints or static env have been provided in the kernel config(5) and the
static versions are mutually exclusive with loader(8)-provided environment.
hintmode *can* be reconfigured later to pull from the dynamic environment,
thus taking advantage of the loader(8) or post-kmem environment setting.
This changeset fixes both problems at once to move us from a semi-confusing
state to a consistent state: if an environment file, hints file, or
loader(8) environment are provided, we use them in a well-known order of
precedence:
- loader(8) environment
- static environment
- static hints file
Once the dynamic environment is setup this becomes a moot point. The
loader(8) and static environments are merged (respecting the above order of
precedence), and the static hints are merged in on an as-needed basis after
the dynamic environment has been setup.
Hints lookup are changed to respect all of the above. Before the dynamic
environment is setup, lookups use the above-mentioned order and fallback to
the next environment if a matching hint is not found. Once the dynamic
environment is setup, that is used on its own since it captures all of the
above information plus any dynamic kenv settings that came up later in boot.
The following tangentially related changes were made to res_find:
- A hintp cookie is now passed in so that related searches continue using
the chain of environments (or dynamic environment) without relying on
global state
- All three environments will be searched if they actually have valid hints
to use, rather than just choosing the first environment that actually had
a hint and rolling with that only
The hintmode sysctl has been ripped out. static_{env,hints}.disabled are
still honored and will disable their respective environments from being used
for hint lookups and from being merged into the dynamic environment, as
expected.
MFC after: 1 month (maybe)
Differential Revision: https://reviews.freebsd.org/D15953
Notes
Notes:
svn path=/head/; revision=335998
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/config.5 | 47 | ||||
-rw-r--r-- | usr.sbin/config/config.h | 2 | ||||
-rw-r--r-- | usr.sbin/config/config.y | 5 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 2 |
4 files changed, 40 insertions, 16 deletions
diff --git a/usr.sbin/config/config.5 b/usr.sbin/config/config.5 index c33661f93937..966d4fe4ae64 100644 --- a/usr.sbin/config/config.5 +++ b/usr.sbin/config/config.5 @@ -114,12 +114,24 @@ are defined in the file .Pp .It Ic env Ar filename Specifies a filename containing a kernel environment definition. -The kernel normally uses an environment prepared for it at boot time -by +.Pp +The kernel will augment this compiled-in environment with the environment +prepared for it at boot time by .Xr loader 8 . -This directive makes the kernel ignore the boot environment and use -the compiled-in environment instead, unless the boot environment contains -.Va static_env.disabled=1 . +Environment variables specified in the +.Xr loader 8 +environment will take precedence over environment variables specified in +.Ar filename , +and environment variables specified in the dynamic environment take precedence +over both of these. +.Pp +.Va static_env.disabled=1 +may be specified in the +.Xr loader 8 +environment to disable use of this compiled-in environment. +This option has no effect if specified in any environment after the +.Xr loader 8 +environment is processed. .Pp This directive is useful for setting kernel tunables in embedded environments that do not start from @@ -172,9 +184,28 @@ time (see .Xr device.hints 5 ) . This directive configures the kernel to use the static device configuration listed in -.Ar filename , -unless the boot environment contains -.Va static_hints.disabled=1 . +.Ar filename . +.Pp +Hints provided in this static device configuration will be overwritten in the +order in which they're encountered. +Hints in the compiled-in environment takes precedence over compiled-in hints, +and hints in the environment prepared for the kernel by +.Xr loader 8 +takes precedence over hints in the compiled-in environment. +.Pp +Once the dynamic environment becomes available, all compiled-in hints will be +added to the dynamic environment if they do not already have an override in +the dynamic environment. +The dynamic environment will then be used for all searches of hints. +.Pp +.Va static_hints.disabled=1 +may be specified in either a compiled-in environment or the +.Xr loader 8 +environment to disable use of these hints files. +This option has no effect if specified in any environment after the +.Xr loader 8 +environment is processed. +.Pp The file .Ar filename must conform to the syntax specified by diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index fd5fb344e791..941a65f60216 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -179,8 +179,6 @@ SLIST_HEAD(, includepath) includepath; extern char *ident; extern char kernconfstr[]; extern int do_trace; -extern int envmode; -extern int hintmode; extern int incignore; char *get_word(FILE *); diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 33658c54a823..f0284123ae43 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -82,8 +82,7 @@ struct device_head dtab; char *ident; -int envmode; -int hintmode; +char *env; int yyline; const char *yyfile; struct file_list_head ftab; @@ -201,7 +200,6 @@ Config_spec: err(EXIT_FAILURE, "calloc"); hint->hint_name = $2; STAILQ_INSERT_HEAD(&hints, hint, hint_next); - hintmode = 1; } System_spec: @@ -361,7 +359,6 @@ newenvvar(char *name, bool is_file) envvar->env_str = name; envvar->env_is_file = is_file; STAILQ_INSERT_HEAD(&envvars, envvar, envvar_next); - envmode = 1; } /* diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 260dd4cf9c42..bc9104b691b7 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -197,7 +197,6 @@ makehints(void) fprintf(ofp, "#include <sys/types.h>\n"); fprintf(ofp, "#include <sys/systm.h>\n"); fprintf(ofp, "\n"); - fprintf(ofp, "int hintmode = %d;\n", hintmode); fprintf(ofp, "char static_hints[] = {\n"); STAILQ_FOREACH(hint, &hints, hint_next) { ifp = fopen(hint->hint_name, "r"); @@ -312,7 +311,6 @@ makeenv(void) fprintf(ofp, "#include <sys/types.h>\n"); fprintf(ofp, "#include <sys/systm.h>\n"); fprintf(ofp, "\n"); - fprintf(ofp, "int envmode = %d;\n", envmode); fprintf(ofp, "char static_env[] = {\n"); STAILQ_FOREACH(envvar, &envvars, envvar_next) { if (envvar->env_is_file) { |