[PATCH 2/4] envfs: provide an intentional way to ignore an existing external environment
Juergen Borleis
jbe at pengutronix.de
Thu Jul 31 03:39:01 PDT 2014
Add a simple flag to envfs to be able to mark an external environment as
"not to be used".
This change should not affect existing systems, because the current envfs
implementation ensures the 'flags' member in the envfs master block is always
zeroed.
Signed-off-by: Juergen Borleis <jbe at pengutronix.de>
---
common/environment.c | 13 +++++++++++++
include/envfs.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/common/environment.c b/common/environment.c
index 2d1edf8..613342c 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -447,6 +447,19 @@ int envfs_load(const char *filename, const char *dir, unsigned flags)
if (ret)
goto out;
+ if (super.flags & ENVFS_FLAGS_FORCE_BUILT_IN) {
+#ifdef __BAREBOX__
+ if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) {
+ ret = defaultenv_load("/env", 0);
+ if (ret)
+ perror("envfs: forced built-in default environment");
+ else
+ printf("envfs: force built-in default environment\n");
+ goto out;
+ }
+#endif
+ }
+
buf = xmalloc(size);
rbuf = buf;
diff --git a/include/envfs.h b/include/envfs.h
index 9b86398..beae38a 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -43,6 +43,7 @@ struct envfs_super {
uint8_t minor; /* minor */
uint16_t future; /* reserved for future use */
uint32_t flags; /* feature flags */
+#define ENVFS_FLAGS_FORCE_BUILT_IN (1 << 0)
uint32_t sb_crc; /* crc for the superblock */
};
--
2.0.1
More information about the barebox
mailing list