Hi,
On 11/03/2017 04:55 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 | 27 +++++++++++++++++++++++++++
include/env_api.h | 2 ++
2 files changed, 29 insertions(+)
diff --git a/env/env_api_fat.c b/env/env_api_fat.c
index 7d5e714..565ab44 100644
--- a/env/env_api_fat.c
+++ b/env/env_api_fat.c
@@ -320,6 +320,29 @@ 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;
+ continue;
+ }
+ int r = bgenv_set_uservar(env->data->userdata, key, type, data,
+ datalen);
+ if (r) {
+ ret = r; > + }
+ if (!bgenv_write(env)) {
+ ret = -EIO;
+ }
+ (void)bgenv_close(env);
+ }
+ return ret;
+}
I don't like that return value is overwritten by succeeding error values
here. Maybe return on the first error would be better. Gracious
programming could lead to bad side effects.
If you have any reason for doing so:
ret = r ? r : ret;
looks better for me than:
if (r) {
ret = r;
}
But thats just subjective and very minor.
Cheers,
Claudius
+
int bgenv_set(BGENV *env, char *key, uint64_t type, void *data,
uint32_t datalen)
{
@@ -337,6 +360,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/abba4ee7-8c57-1ca7-9e9f-45f69decd44a%40siemens.com.
For more options, visit https://groups.google.com/d/optout.