From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] environment: detect command_abi_version
Date: Mon, 22 Oct 2012 18:07:28 +0200 [thread overview]
Message-ID: <1350922048-25699-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1350922048-25699-1-git-send-email-plagnioj@jcrosoft.com>
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@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-10-22 16:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 16:03 [PATCH 0/3] introduce command abi version Jean-Christophe PLAGNIOL-VILLARD
2012-10-22 16:07 ` [PATCH 1/3] command: introduce " Jean-Christophe PLAGNIOL-VILLARD
2012-10-22 16:07 ` [PATCH 2/3] envfs: add command_abi_version support Jean-Christophe PLAGNIOL-VILLARD
2012-10-23 8:59 ` Sascha Hauer
2012-10-23 10:20 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-23 12:56 ` Sascha Hauer
2012-10-23 13:27 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-22 16:07 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-10-29 8:50 ` [PATCH 1/3] command: introduce abi version Sascha Hauer
2012-10-29 9:56 ` Johannes Stezenbach
2012-10-29 10:31 ` Sascha Hauer
2012-10-29 16:05 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-29 17:00 ` Johannes Stezenbach
2012-10-29 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-23 8:51 ` [PATCH 0/3] introduce command " Sascha Hauer
2012-10-23 10:28 ` Jean-Christophe PLAGNIOL-VILLARD
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=1350922048-25699-3-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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