mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
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>
This commit is contained in:
committed by
Tom Rini
parent
2598090b7e
commit
30fd4fadb3
3
tools/env/Makefile
vendored
3
tools/env/Makefile
vendored
@@ -24,12 +24,15 @@
|
||||
include $(TOPDIR)/config.mk
|
||||
|
||||
HOSTSRCS := $(SRCTREE)/lib/crc32.c fw_env.c fw_env_main.c
|
||||
HOSTSRCS += $(SRCTREE)/lib/ctype.c $(SRCTREE)/lib/linux_string.c
|
||||
HOSTSRCS += $(SRCTREE)/common/env_attr.c $(SRCTREE)/common/env_flags.c
|
||||
HEADERS := fw_env.h $(OBJTREE)/include/config.h
|
||||
|
||||
# Compile for a hosted environment on the target
|
||||
HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
|
||||
-idirafter $(OBJTREE)/include2 \
|
||||
-idirafter $(OBJTREE)/include \
|
||||
-idirafter $(SRCTREE)/tools/env \
|
||||
-DUSE_HOSTCC \
|
||||
-DTEXT_BASE=$(TEXT_BASE)
|
||||
|
||||
|
||||
9
tools/env/fw_env.c
vendored
9
tools/env/fw_env.c
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user