From: Florijan Plohl <florijan.plohl@norik.com>
To: s.hauer@pengutronix.de, barebox@lists.infradead.org
Cc: upstream@lists.phytec.de, a.fatoum@pengutronix.de
Subject: [RFC PATCH 1/2] defaultenv: add defaultenv_append_external() to re-apply BSP environment
Date: Wed, 7 Oct 2026 07:59:52 +0200 [thread overview]
Message-ID: <20261007055953.1001705-2-florijan.plohl@norik.com> (raw)
In-Reply-To: <20261007055953.1001705-1-florijan.plohl@norik.com>
From: Primoz Fiser <primoz.fiser@norik.com>
Since commit 7f1cc5dd869d ("defaultenv: add base and external
defaultenv in pure_initcall"), the Kconfig/BSP-supplied environment
(CONFIG_DEFAULT_ENVIRONMENT_PATH) is appended to the defaultenv list
once, very early, from a pure_initcall. Board code that appends its
own defaultenv directories later (e.g. from a postcore_platform_driver
probe, via defaultenv_append_directory()) now wins any path collision
against it, since defaultenv_append() is a plain list_add_tail() with
last-appended-wins semantics.
Boards that still want the BSP-supplied environment to take final
precedence over their own board-specific defaults (e.g. to keep a
board-level fallback environment for standalone/non-Yocto builds while
still letting a Yocto BSP's per-machine environment win when supplied)
have no way to reassert it after their own appends.
Add defaultenv_append_external(), a small wrapper that re-appends the
already-compiled-in BSP environment blob. Boards can call it after
their own defaultenv_append_directory() calls to restore the
pre-7f1cc5dd869d precedence where it matters.
Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>
Signed-off-by: Florijan Plohl <florijan.plohl@norik.com>
---
defaultenv/defaultenv.c | 16 ++++++++++++++++
include/envfs.h | 5 +++++
2 files changed, 21 insertions(+)
diff --git a/defaultenv/defaultenv.c b/defaultenv/defaultenv.c
index 573b1f862f..626218477b 100644
--- a/defaultenv/defaultenv.c
+++ b/defaultenv/defaultenv.c
@@ -166,3 +166,19 @@ static int defaultenv_init(void)
return 0;
}
pure_initcall(defaultenv_init);
+
+/*
+ * defaultenv_init() (pure_initcall) already appends the Kconfig/BSP-supplied
+ * environment (DEFAULT_ENVIRONMENT_PATH) once, early. Boards that append
+ * their own board-specific defaultenv directories later (e.g. from a
+ * postcore_platform_driver probe) win any path collision, since
+ * defaultenv_append() is plain list_add_tail() / last-appended-wins.
+ * Call this after such board-specific appends to make the Kconfig/BSP
+ * environment win again instead - restores the pre-pure_initcall
+ * precedence for that board.
+ */
+void defaultenv_append_external(void)
+{
+ defaultenv_append((void *)default_environment,
+ default_environment_size, "defaultenv");
+}
diff --git a/include/envfs.h b/include/envfs.h
index 0c6b2e6815..a3b5a8bd98 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -134,6 +134,7 @@ static inline const char *of_env_get_device_alias_by_path(const char *of_path)
#ifdef CONFIG_DEFAULT_ENVIRONMENT
void defaultenv_append(void *buf, unsigned int size, const char *name);
void defaultenv_append_runtime_directory(const char *srcdir);
+void defaultenv_append_external(void);
int defaultenv_load(const char *dir, unsigned flags);
#else
static inline void defaultenv_append(void *buf, unsigned int size, const char *name)
@@ -144,6 +145,10 @@ static inline void defaultenv_append_runtime_directory(const char *srcdir)
{
}
+static inline void defaultenv_append_external(void)
+{
+}
+
static inline int defaultenv_load(const char *dir, unsigned flags)
{
return -ENOSYS;
--
2.43.0
next prev parent reply other threads:[~2026-10-07 6:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 5:59 [RFC PATCH 0/2] defaultenv: board defaultenv now overrides CONFIG_DEFAULT_ENVIRONMENT_PATH Florijan Plohl
2026-10-07 5:59 ` Florijan Plohl [this message]
2026-10-07 5:59 ` [RFC PATCH 2/2] ARM: boards: phytec-som-imx6: re-apply BSP environment after board defaultenv Florijan Plohl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261007055953.1001705-2-florijan.plohl@norik.com \
--to=florijan.plohl@norik.com \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
--cc=upstream@lists.phytec.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox