[U-Boot] [RFC 1/3] tools/env: Default to the config specified in FW_CONFIG_FILE

Steve Sakoman
2010-12-04T04:28:51Z

From: Lo?c Minier <loic.minier@linaro.org>

This patch allows one to override the default location of
the config file by setting FW_CONFIG_FILE environment variable.

Signed-off-by: Lo?c Minier <loic.minier@linaro.org>
Tested-by: Steve Sakoman <steve@sakoman.com>
---
tools/env/fw_env.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 8ff7052..75f6a98 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1224,8 +1224,15 @@ static int parse_config ()
struct stat st;

#if defined(CONFIG_FILE)
+ /* Default to the config file specified in FW_CONFIG_FILE */
+ char *config_file = getenv("FW_CONFIG_FILE");
+ if (!config_file || !strlen(config_file)) {
+ /* If unset or empty use the default config file */
+ config_file = CONFIG_FILE;
+ }
+
/* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
- if (get_config (CONFIG_FILE)) {
+ if (get_config (config_file)) {
fprintf (stderr,
"Cannot parse config file: %s\n", strerror (errno));
return -1;
--
1.7.0.4