diff options
author | Grant Erickson <marathon96@gmail.com> | 2011-12-22 08:59:55 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2012-01-05 17:00:01 +0100 |
commit | aa701b94336b358798d676eef12a7b90bdac23f5 (patch) | |
tree | 9668dfa693be46dfda9c49cf90aeabfcfde79b7d /tools/env | |
parent | 145afab32c3a049bd646d2eede5f2feba08576c6 (diff) | |
download | u-boot-imx-aa701b94336b358798d676eef12a7b90bdac23f5.zip u-boot-imx-aa701b94336b358798d676eef12a7b90bdac23f5.tar.gz u-boot-imx-aa701b94336b358798d676eef12a7b90bdac23f5.tar.bz2 |
tools/env: allow overwrite of ethaddr on default
This patch allows the U-Boot user space companion utility, fw_setenv,
to overwrite the 'ethaddr' key/value pair if the current value is set
to a per-board-configured default.
This change allows 'fw_setenv' to match the behavior of 'setenv' /
'env set' on the U-Boot command line.
Signed-off-by: Grant Erickson <marathon96@gmail.com>
Fixed excessive white space.
Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'tools/env')
-rw-r--r-- | tools/env/fw_env.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 996682e..e292d2b 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -45,6 +45,8 @@ #include "fw_env.h" +#include <config.h> + #define WHITESPACE(c) ((c == '\t') || (c == ' ')) #define min(x, y) ({ \ @@ -390,15 +392,22 @@ int fw_env_write(char *name, char *value) * Delete any existing definition */ if (oldval) { +#ifndef CONFIG_ENV_OVERWRITE /* * Ethernet Address and serial# can be set only once */ - if ((strcmp (name, "ethaddr") == 0) || - (strcmp (name, "serial#") == 0)) { + if ( + (strcmp(name, "serial#") == 0) || + ((strcmp(name, "ethaddr") == 0) +#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) + && (strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0) +#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ + ) ) { fprintf (stderr, "Can't overwrite \"%s\"\n", name); errno = EROFS; return -1; } +#endif /* CONFIG_ENV_OVERWRITE */ if (*++nxt == '\0') { *env = '\0'; |