From 5ab81058364b5e49bdc6f530368d49e94dfcb960 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 3 Feb 2023 13:22:51 +0100 Subject: env: Complete generic support for writable list This completes what 890feecaab72 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 CC: Marek Vasut CC: Stefan Herbrechtsmeier Signed-off-by: Jan Kiszka Reviewed-by: Marek Vasut --- env/Kconfig | 1 + env/env.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'env') diff --git a/env/Kconfig b/env/Kconfig index c409ea71fe..6e24eee55f 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -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 diff --git a/env/env.c b/env/env.c index 0f73ebc08e..ad774f4117 100644 --- a/env/env.c +++ b/env/env.c @@ -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; -- cgit v1.2.3