[PATCH V3 01/13] env: Complete generic support for writable list
Jan Kiszka
jan.kiszka at siemens.com
Fri Nov 4 12:23:48 CET 2022
From: Jan Kiszka <jan.kiszka at siemens.com>
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 <joe.hershberger at ni.com>
CC: Marek Vasut <marex at denx.de>
CC: Stefan Herbrechtsmeier <stefan.herbrechtsmeier-oss at weidmueller.com>
Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
---
env/Kconfig | 1 +
env/env.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/env/Kconfig b/env/Kconfig
index 24111dfaf47..3d818cc94fb 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -715,6 +715,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 69848fb0608..f9c45404753 100644
--- a/env/env.c
+++ b/env/env.c
@@ -195,6 +195,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;
--
2.35.3
More information about the U-Boot
mailing list