diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2012-12-11 22:16:31 -0600 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-12-13 11:46:56 -0700 |
commit | 2598090b7e17f8bdca95b22e7f27217054730e02 (patch) | |
tree | 08c613d02581cdf4238736511cc10d5f3c782990 /common/cmd_nvedit.c | |
parent | e080d545f8ffb104a13b07deddf92ecb498b3a94 (diff) | |
download | u-boot-2598090b7e17f8bdca95b22e7f27217054730e02.zip u-boot-2598090b7e17f8bdca95b22e7f27217054730e02.tar.gz u-boot-2598090b7e17f8bdca95b22e7f27217054730e02.tar.bz2 |
env: Add environment variable flags
Currently just validates variable types as decimal, hexidecimal,
boolean, ip address, and mac address.
If the entry is not found in the env ".flags", then look in the static
one. This allows the env to override the static definitions, but prevents
the need to have every definition in the environment distracting you.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common/cmd_nvedit.c')
-rw-r--r-- | common/cmd_nvedit.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index cb191cd..f645194 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -192,57 +192,9 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag, #endif /* CONFIG_SPL_BUILD */ /* - * Perform consistency checking before setting, replacing, or deleting an - * environment variable, then (if successful) apply the changes to internals so - * to make them effective. Code for this function was taken out of - * _do_env_set(), which now calls it instead. - * Also called as a callback function by himport_r(). - * Returns 0 in case of success, 1 in case of failure. - * When (flag & H_FORCE) is set, do not print out any error message and force - * overwriting of write-once variables. - */ - -int env_change_ok(const ENTRY *item, const char *newval, enum env_op op, - int flag) -{ -#ifndef CONFIG_ENV_OVERWRITE - const char *name; -#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) - const char *oldval = NULL; - - if (op != env_op_create) - oldval = item->data; -#endif - - name = item->key; -#endif - -#ifndef CONFIG_ENV_OVERWRITE - /* - * Some variables like "ethaddr" and "serial#" can be set only once and - * cannot be deleted, unless CONFIG_ENV_OVERWRITE is defined. - */ - if (op != env_op_create && /* variable exists */ - (flag & H_FORCE) == 0) { /* and we are not forced */ - if (strcmp(name, "serial#") == 0 || - (strcmp(name, "ethaddr") == 0 -#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) - && strcmp(oldval, __stringify(CONFIG_ETHADDR)) != 0 -#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ - )) { - printf("Can't overwrite \"%s\"\n", name); - return 1; - } - } -#endif - - return 0; -} - -/* * Set a new environment variable, * or replace or delete an existing one. -*/ + */ static int _do_env_set(int flag, int argc, char * const argv[]) { int i, len; |