HomeFreeBSD

Fix kenv handling in stable/11 following r337333

Description

Fix kenv handling in stable/11 following r337333

The aforementioned commit merged revised static_env/static_hint handling to
allow static_env and loader env to coexist with the variable
loader_env.disabled=0. init_static_kenv had been rewritten slighly in an
attempt to maintain historical behavior: the static environment and loader
environment are mutually exclusive, unless the latter disables the former.

The rewritten version botched this by only setting up the loader environment
if the static environment was empty or if the loader environment was
specifically enabled. It was never given a chance to disable the static
environment, so the default behavior was broken unless the loader
environment was specifically enabled by the static environment.

Rewrite this again to do the right thing:

  • Setup the static environment and check loader_env.disabled; if it's explicitly enabled, we're done.
  • Check static_{env,hints}.disabled and "empty out" the respective environments as needed
  • Finally, check: if the static environment is not empty and we've not explicitly re-enabled the static environment with loader_env.disabled=0, we tear the loader environment (which was setup to 'keep things simple') down again.

Future commits to head (and subsequently MFC'd) will likely zero these
environments out if they're disabled since this normally happens when
they're merged into the dynamic environment.

This is a direct commit to stable/11 because this particular bug does not
apply to head.

Fixes: r337333
Reported by: bde

Details

Provenance
kevansAuthored on
Parents
rS341643: Change u32 to uint32_t to allow the native-xtools target to build
Branches
Unknown
Tags
Unknown