--- embedtools/src/ub_env.c 2014/01/28 22:50:37 1.1.2.6 +++ embedtools/src/ub_env.c 2014/01/28 23:04:42 1.1.2.7 @@ -8,9 +8,10 @@ env_t *env; static int ub_flash_io(const char *csSec, int mode) { - int f, rlen, ret = 0; + int f, l, rlen; const char *str; size_t siz; + ait_val_t v; FTRACE(4); @@ -24,9 +25,20 @@ ub_flash_io(const char *csSec, int mode) return -1; } + cfg_loadAttribute(&cfg, "ube", "lock", &v, UBE_LOCK); + l = open(AIT_GET_STR(&v), 0644, O_CREAT | O_EXCL | O_WRONLY); + if (l == -1) { + printf("Error:: Locked u-boot-env map!\n"); + AIT_FREE_VAL(&v); + return -1; + } + f = open(str, mode); if (f == -1) { printf("Error:: Can't access u-boot-env device %s\n", str); + close(l); + unlink(AIT_GET_STR(&v)); + AIT_FREE_VAL(&v); return -1; } @@ -46,7 +58,10 @@ ub_flash_io(const char *csSec, int mode) VERB(3) printf("Readed %d bytes\n", rlen); close(f); - return ret; + close(l); + unlink(AIT_GET_STR(&v)); + AIT_FREE_VAL(&v); + return 0; } int @@ -68,7 +83,7 @@ ub_load(const char *csSec) return -1; } - return 0; + return ub_flash_io(csSec, O_RDONLY); } void