Hi,
On 11/07/2017 03:12 PM, [ext] Andreas J. Reichel wrote:
From: Andreas Reichel <[email protected]>
If the above flag is set in the type field of a user variable,
bgenv_set_uservar_global is called, which iterates all environments
and stores the given variable globally.
If the flag is absent, only the environment specified by the context
handle gets affected.
The flag is set per default if not otherwise specified.
Signed-off-by: Andreas Reichel <[email protected]>
---
env/env_api_fat.c | 36 ++++++++++++++++++++++++++++++++++++
include/env_api.h | 2 ++
2 files changed, 38 insertions(+)
diff --git a/env/env_api_fat.c b/env/env_api_fat.c
index 7d5e714..0aef867 100644
--- a/env/env_api_fat.c
+++ b/env/env_api_fat.c
@@ -320,6 +320,38 @@ int bgenv_get(BGENV *env, char *key, uint64_t *type, void
*data,
return 0;
}
+int bgenv_set_uservar_global(char *key, uint64_t type, void *data,
+ uint32_t datalen)
+{
+ int ret = 0;
+ for (int i = 0; i < ENV_NUM_CONFIG_PARTS; i++) {
+ BGENV *env = bgenv_open_by_index(i);
+ if (!env) {
+ ret = -EIO;
+ VERBOSE(stderr, "bgenv_set_uservar_global: Could not "
+ "open config partition #%d: (%s)\n",
+ i, strerror(-ret));
Not sure what 'VERBOSE' should stand for. Is is more for debugging
messages or for any message?
I would expect that errors that occurred should be printed out
regardless of the logging level.
Claudius
+ continue;
+ }
+ int r = bgenv_set_uservar(env->data->userdata, key, type, data,
+ datalen);
+ if (r) {
+ VERBOSE(stderr, "bgenv_set_uservar_global: Could not "
+ "set uservar on config partition "
+ " #%d: (%s)\n", i, strerror(-r));
+ ret = r;
+ }
+ if (!bgenv_write(env)) {
+ ret = -EIO;
+ VERBOSE(stderr, "bgenv_set_uservar_global: Could not "
+ " store environment to partition "
+ " #%d: (%s)\n", i, strerror(-ret));
+ }
+ (void)bgenv_close(env);
+ }
+ return ret;
+}
+
int bgenv_set(BGENV *env, char *key, uint64_t type, void *data,
uint32_t datalen)
{
@@ -337,6 +369,10 @@ int bgenv_set(BGENV *env, char *key, uint64_t type, void
*data,
return -EPERM;
}
if (e == EBGENV_UNKNOWN) {
+ if (type & USERVAR_TYPE_GLOBAL) {
+ return bgenv_set_uservar_global(key, type, data,
+ datalen);
+ }
return bgenv_set_uservar(env->data->userdata, key, type, data,
datalen);
}
diff --git a/include/env_api.h b/include/env_api.h
index 8ea2c11..3b1ba1f 100644
--- a/include/env_api.h
+++ b/include/env_api.h
@@ -83,5 +83,7 @@ extern int bgenv_get(BGENV *env, char *key, uint64_t *type,
void *data,
uint32_t maxlen);
extern int bgenv_set(BGENV *env, char *key, uint64_t type, void *data,
uint32_t datalen);
+extern int bgenv_set_uservar_global(char *key, uint64_t type,
+ void *data, uint32_t datalen);
#endif // __ENV_API_H__
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: [email protected]
--
You received this message because you are subscribed to the Google Groups "EFI Boot
Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/68a0e545-9671-79af-1235-0b8f60cea4b6%40siemens.com.
For more options, visit https://groups.google.com/d/optout.