summaryrefslogtreecommitdiff
path: root/tools/env/fw_env.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-12 04:16:32 (GMT)
committerTom Rini <trini@ti.com>2012-12-13 18:46:56 (GMT)
commit30fd4fadb319d7c6d43d949e2d30ffaea46a60cf (patch)
treecedfa8c38a45f3f6afe046a999003e56a609c84d /tools/env/fw_env.c
parent2598090b7e17f8bdca95b22e7f27217054730e02 (diff)
downloadu-boot-fsl-qoriq-30fd4fadb319d7c6d43d949e2d30ffaea46a60cf.tar.xz
tools/env: Add environment variable flags support
Currently just validates variable types as decimal, hexidecimal, boolean, ip address, and mac address. Call env_acl_validate_setenv_params() from setenv() in fw_env.c. 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. Need to build in _ctype for isdigit for Linux. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'tools/env/fw_env.c')
-rw-r--r--tools/env/fw_env.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 9b023e8..5be36fc 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -25,6 +25,7 @@
*/
#include <errno.h>
+#include <env_flags.h>
#include <fcntl.h>
#include <linux/stringify.h>
#include <stdio.h>
@@ -395,6 +396,9 @@ int fw_setenv(int argc, char *argv[])
name = argv[1];
+ if (env_flags_validate_env_set_params(argc, argv) < 0)
+ return 1;
+
len = 0;
for (i = 2; i < argc; ++i) {
char *val = argv[i];
@@ -516,6 +520,11 @@ int fw_parse_script(char *fname)
name, val ? val : " removed");
#endif
+ if (env_flags_validate_type(name, val) < 0) {
+ ret = -1;
+ break;
+ }
+
/*
* If there is an error setting a variable,
* try to save the environment and returns an error