summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2011-11-06 22:49:44 +0100
committerWolfgang Denk <wd@denx.de>2011-11-08 13:20:42 +0100
commit37f2fe7472a34531e7d585eb7e0730b4f8e1f213 (patch)
treedf4a0306161ef740045c011f6847ed50fb47a120 /common
parent5721385b187b3154c7768e6c182501022f4e2e45 (diff)
downloadu-boot-imx-37f2fe7472a34531e7d585eb7e0730b4f8e1f213.zip
u-boot-imx-37f2fe7472a34531e7d585eb7e0730b4f8e1f213.tar.gz
u-boot-imx-37f2fe7472a34531e7d585eb7e0730b4f8e1f213.tar.bz2
env: allow to export only selected variables
New syntax: env export [-t | -b | -c] [-s size] addr [var ...] With this change it is possible to provide a list of variables names that shall be exported. Whenno arguments are given, the whole environment gets exported. NOTE: The new handling of the "size" argument means a change to the user API. Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_nvedit.c33
-rw-r--r--common/env_dataflash.c2
-rw-r--r--common/env_eeprom.c2
-rw-r--r--common/env_flash.c4
-rw-r--r--common/env_mmc.c2
-rw-r--r--common/env_nand.c4
-rw-r--r--common/env_nvram.c2
-rw-r--r--common/env_onenand.c2
-rw-r--r--common/env_sf.c4
9 files changed, 32 insertions, 23 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 396a171..7194ade 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -125,7 +125,7 @@ static int env_print(char *name)
}
/* print whole list */
- len = hexport_r(&env_htab, '\n', &res, 0);
+ len = hexport_r(&env_htab, '\n', &res, 0, 0, NULL);
if (len > 0) {
puts(res);
@@ -647,7 +647,7 @@ static int do_env_delete(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
#ifdef CONFIG_CMD_EXPORTENV
/*
- * env export [-t | -b | -c] addr [size]
+ * env export [-t | -b | -c] [-s size] addr [var ...]
* -t: export as text format; if size is given, data will be
* padded with '\0' bytes; if not, one terminating '\0'
* will be added (which is included in the "filesize"
@@ -657,8 +657,12 @@ static int do_env_delete(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
* '\0', list end marked by double "\0\0")
* -c: export as checksum protected environment format as
* used for example by "saveenv" command
+ * -s size:
+ * size of output buffer
* addr: memory address where environment gets stored
- * size: size of output buffer
+ * var... List of variable names that get included into the
+ * export. Without arguments, the whole environment gets
+ * exported.
*
* With "-c" and size is NOT given, then the export command will
* format the data as currently used for the persistent storage,
@@ -691,7 +695,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
{
char buf[32];
char *addr, *cmd, *res;
- size_t size;
+ size_t size = 0;
ssize_t len;
env_t *envp;
char sep = '\n';
@@ -715,6 +719,11 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
sep = '\0';
chk = 1;
break;
+ case 's': /* size given */
+ if (--argc <= 0)
+ return cmd_usage(cmdtp);
+ size = simple_strtoul(*++argv, NULL, 16);
+ goto NXTARG;
case 't': /* text format */
if (fmt++)
goto sep_err;
@@ -724,6 +733,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
return cmd_usage(cmdtp);
}
}
+NXTARG: ;
}
if (argc < 1)
@@ -731,15 +741,14 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
addr = (char *)simple_strtoul(argv[0], NULL, 16);
- if (argc == 2) {
- size = simple_strtoul(argv[1], NULL, 16);
+ if (size)
memset(addr, '\0', size);
- } else {
- size = 0;
- }
+
+ argc--;
+ argv++;
if (sep) { /* export as text file */
- len = hexport_r(&env_htab, sep, &addr, size);
+ len = hexport_r(&env_htab, sep, &addr, size, argc, argv);
if (len < 0) {
error("Cannot export environment: errno = %d\n",
errno);
@@ -758,7 +767,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
else /* export as raw binary data */
res = addr;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, argc, argv);
if (len < 0) {
error("Cannot export environment: errno = %d\n",
errno);
@@ -965,7 +974,7 @@ U_BOOT_CMD(
#if defined(CONFIG_CMD_EDITENV)
"env edit name - edit environment variable\n"
#endif
- "env export [-t | -b | -c] addr [size] - export environment\n"
+ "env export [-t | -b | -c] [-s size] addr [var ...] - export environment\n"
#if defined(CONFIG_CMD_GREPENV)
"env grep string [...] - search environment\n"
#endif
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index 1d57079..0c4c676 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -68,7 +68,7 @@ int saveenv(void)
char *res;
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 0a179ad..1233b1a 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -143,7 +143,7 @@ int saveenv(void)
BUG_ON(env_ptr != NULL);
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_flash.c b/common/env_flash.c
index 50ca4ffa..8e415d7 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -155,7 +155,7 @@ int saveenv(void)
}
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;
@@ -289,7 +289,7 @@ int saveenv(void)
goto done;
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 83f40f4..12d647a 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -124,7 +124,7 @@ int saveenv(void)
return 1;
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_nand.c b/common/env_nand.c
index 14446a6..da4d3b1 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -200,7 +200,7 @@ int saveenv(void)
return 1;
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
@@ -255,7 +255,7 @@ int saveenv(void)
return 1;
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 544ce47..b108e6e 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -94,7 +94,7 @@ int saveenv(void)
int rcode = 0;
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_onenand.c b/common/env_onenand.c
index 5e04a06..4144475 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -109,7 +109,7 @@ int saveenv(void)
};
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_sf.c b/common/env_sf.c
index d3b36d0..a1ff297 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -91,7 +91,7 @@ int saveenv(void)
}
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
@@ -293,7 +293,7 @@ int saveenv(void)
}
res = (char *)&env_new.data;
- len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;