Skip to content

Commit

Permalink
env: Complete generic support for writable list
Browse files Browse the repository at this point in the history
This completes what 890feec started by selecting ENV_APPEND and
loading the default env before any other sources. This ensures that load
operations pick up all non-writable vars from the default env and only
permitted parts from other locations according to the regular
priorities.

With this change, boards only need to define the list of writable
variables but no longer have to provide a custom env_get_location
implementation.

CC: Joe Hershberger <[email protected]>
CC: Marek Vasut <[email protected]>
CC: Stefan Herbrechtsmeier <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
Reviewed-by: Marek Vasut <[email protected]>
  • Loading branch information
jan-kiszka authored and trini committed Feb 10, 2023
1 parent 0106504 commit 5ab8105
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions env/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ config ENV_APPEND

config ENV_WRITEABLE_LIST
bool "Permit write access only to listed variables"
select ENV_APPEND
help
If defined, only environment variables which explicitly set the 'w'
writeable flag can be written and modified at runtime. No variables
Expand Down
8 changes: 8 additions & 0 deletions env/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ int env_load(void)
int best_prio = -1;
int prio;

if (CONFIG_IS_ENABLED(ENV_WRITEABLE_LIST)) {
/*
* When using a list of writeable variables, the baseline comes
* from the built-in default env. So load this first.
*/
env_set_default(NULL, 0);
}

for (prio = 0; (drv = env_driver_lookup(ENVOP_LOAD, prio)); prio++) {
int ret;

Expand Down

0 comments on commit 5ab8105

Please sign in to comment.