summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:35 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:56 -0700
commit24ab5a1914283b891fa50bc285128bc5fd4ac50a (patch)
treeb9cd4e90aac3283a4b05499c0b4b02d614bf04ec /common
parent267541f776f1e2bec21681c6e39a4c93af9621cf (diff)
downloadu-boot-imx-24ab5a1914283b891fa50bc285128bc5fd4ac50a.zip
u-boot-imx-24ab5a1914283b891fa50bc285128bc5fd4ac50a.tar.gz
u-boot-imx-24ab5a1914283b891fa50bc285128bc5fd4ac50a.tar.bz2
env: Add setenv force support
Now that we have support for permissions, add a way to override them. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_nvedit.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e8dfbf5..988d6b3 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -200,7 +200,24 @@ static int _do_env_set(int flag, int argc, char * const argv[])
int i, len;
char *name, *value, *s;
ENTRY e, *ep;
+ int env_flag = H_INTERACTIVE;
+ debug("Initial value for argc=%d\n", argc);
+ while (argc > 1 && **(argv + 1) == '-') {
+ char *arg = *++argv;
+
+ --argc;
+ while (*++arg) {
+ switch (*arg) {
+ case 'f': /* force */
+ env_flag |= H_FORCE;
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+ }
+ }
+ debug("Final value for argc=%d\n", argc);
name = argv[1];
value = argv[2];
@@ -214,7 +231,7 @@ static int _do_env_set(int flag, int argc, char * const argv[])
/* Delete only ? */
if (argc < 3 || argv[2] == NULL) {
- int rc = hdelete_r(name, &env_htab, H_INTERACTIVE);
+ int rc = hdelete_r(name, &env_htab, env_flag);
return !rc;
}
@@ -241,7 +258,7 @@ static int _do_env_set(int flag, int argc, char * const argv[])
e.key = name;
e.data = value;
- hsearch_r(e, ENTER, &ep, &env_htab, H_INTERACTIVE);
+ hsearch_r(e, ENTER, &ep, &env_htab, env_flag);
free(value);
if (!ep) {
printf("## Error inserting \"%s\" variable, errno=%d\n",
@@ -1109,10 +1126,10 @@ U_BOOT_CMD_COMPLETE(
U_BOOT_CMD_COMPLETE(
setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
"set environment variables",
- "name value ...\n"
- " - set environment variable 'name' to 'value ...'\n"
- "setenv name\n"
- " - delete environment variable 'name'",
+ "[-f] name value ...\n"
+ " - [forcibly] set environment variable 'name' to 'value ...'\n"
+ "setenv [-f] name\n"
+ " - [forcibly] delete environment variable 'name'",
var_complete
);