mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/7] environment: make default env path configurable
Date: Mon, 11 Apr 2011 16:18:37 +0200	[thread overview]
Message-ID: <1302531521-7439-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1302531521-7439-1-git-send-email-s.hauer@pengutronix.de>

Normally the default path to save the environment is /dev/env0. However,
we can't map a file in a fat filesystem to /dev/env0. So if we want to
store the environment in a file in fat we have to make it configurable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/loadenv.c    |    2 +-
 commands/saveenv.c    |    2 +-
 common/environment.c  |    2 ++
 common/startup.c      |    7 ++++---
 include/environment.h |    3 +++
 5 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/commands/loadenv.c b/commands/loadenv.c
index c33c34f..5568ace 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -36,7 +36,7 @@ static int do_loadenv(struct command *cmdtp, int argc, char *argv[])
 	else
 		dirname = argv[2];
 	if (argc < 2)
-		filename = "/dev/env0";
+		filename = default_environment_path;
 	else
 		filename = argv[1];
 	printf("loading environment from %s\n", filename);
diff --git a/commands/saveenv.c b/commands/saveenv.c
index 2f969fe..11a9fee 100644
--- a/commands/saveenv.c
+++ b/commands/saveenv.c
@@ -41,7 +41,7 @@ static int do_saveenv(struct command *cmdtp, int argc, char *argv[])
 	else
 		dirname = argv[2];
 	if (argc < 2)
-		filename = "/dev/env0";
+		filename = default_environment_path;
 	else
 		filename = argv[1];
 
diff --git a/common/environment.c b/common/environment.c
index e5f24ec..0fdbd03 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -44,6 +44,8 @@
 #define EXPORT_SYMBOL(x)
 #endif
 
+char *default_environment_path = "/dev/env0";
+
 int file_size_action(const char *filename, struct stat *statbuf,
 			    void *userdata, int depth)
 {
diff --git a/common/startup.c b/common/startup.c
index 3808709..00bc9a0 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -144,10 +144,11 @@ void start_barebox (void)
 	display_meminfo();
 
 #ifdef CONFIG_ENV_HANDLING
-	if (envfs_load("/dev/env0", "/env")) {
+	if (envfs_load(default_environment_path, "/env")) {
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
-		printf("no valid environment found on /dev/env0. "
-			"Using default environment\n");
+		printf("no valid environment found on %s. "
+			"Using default environment\n",
+			default_environment_path);
 		envfs_load("/dev/defaultenv", "/env");
 #endif
 	}
diff --git a/include/environment.h b/include/environment.h
index 1f22fcb..da032e2 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -62,6 +62,9 @@ static inline int setenv(const char *var, const char *val)
 int env_pop_context(void);
 int env_push_context(void);
 
+/* defaults to /dev/env0 */
+extern char *default_environment_path;
+
 int envfs_load(char *filename, char *dirname);
 int envfs_save(char *filename, char *dirname);
 
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-04-11 14:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 14:18 assorted patches Sascha Hauer
2011-04-11 14:18 ` [PATCH 1/7] eth: check the result of edev->get_ethaddr Sascha Hauer
2011-04-11 14:18 ` [PATCH 2/7] net: add a context to the packet handler Sascha Hauer
2011-04-11 14:18 ` Sascha Hauer [this message]
2011-04-11 14:18 ` [PATCH 4/7] move simple_itoa to libbb so that others can use it Sascha Hauer
2011-04-11 14:18 ` [PATCH 5/7] kfifo: kfifo_put takes a const buffer Sascha Hauer
2011-04-11 14:18 ` [PATCH 6/7] copy_file: handle write return value correctly Sascha Hauer
2011-04-11 14:18 ` [PATCH 7/7] cp command: handle directories as last argument Sascha Hauer

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=1302531521-7439-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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