[PATCH 3/3] environment: detect command_abi_version
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Mon Oct 22 12:07:28 EDT 2012
Detect the environment command_abi_version and if not compatible swith to the
defaultenv. The user will still able to force the laod via loadenv command.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
common/startup.c | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index affb5a9..df6edfa 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -88,6 +88,36 @@ static int mount_root(void)
fs_initcall(mount_root);
#endif
+static void env_handling(void)
+{
+ uint16_t command_abi_version;
+
+ if (!IS_ENABLED(CONFIG_ENV_HANDLING))
+ return;
+
+ if (envfs_load(default_environment_path, "/env", &command_abi_version)) {
+ if (!IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT))
+ return;
+
+ printf("no valid environment found on %s\n",
+ default_environment_path);
+ goto load_defaultenv;
+ }
+
+ if (command_abi_version < COMMAND_ABI_VERSION) {
+ printf("environment found on %s have command_abi_version (%u) < current version (%u)\n",
+ default_environment_path,
+ command_abi_version, COMMAND_ABI_VERSION);
+ goto load_defaultenv;
+ }
+
+ return;
+
+load_defaultenv:
+ printf("Using default environment\n");
+ envfs_load("/dev/defaultenv", "/env", NULL);
+}
+
void start_barebox (void)
{
initcall_t *initcall;
@@ -105,16 +135,8 @@ void start_barebox (void)
debug("initcalls done\n");
-#ifdef CONFIG_ENV_HANDLING
- if (envfs_load(default_environment_path, "/env", NULL)) {
-#ifdef CONFIG_DEFAULT_ENVIRONMENT
- printf("no valid environment found on %s. "
- "Using default environment\n",
- default_environment_path);
- envfs_load("/dev/defaultenv", "/env", NULL);
-#endif
- }
-#endif
+ env_handling();
+
#ifdef CONFIG_COMMAND_SUPPORT
printf("running /env/bin/init...\n");
--
1.7.10.4
More information about the barebox
mailing list