Signed-off-by: Tobias Schmidl <[email protected]>
---
env/env_user_config_file.c | 37 +++++++++++++++++++++++++------------
include/envdata.h | 8 ++++++++
2 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/env/env_user_config_file.c b/env/env_user_config_file.c
index 8d20ed3..4b24d9c 100644
--- a/env/env_user_config_file.c
+++ b/env/env_user_config_file.c
@@ -83,31 +83,44 @@ int env_user_config_file_read(const char *file_name,
BG_ENVDATA *data,
const char *key = keys[j] + prefix_index + 1;
const char *value =
iniparser_getstring(ini_file, keys[j], NULL);
- if (strcmp(key, "kernelfile") == 0 &&
+ if (strcmp(key, BG_ENV_KERNELFILE_STRING) == 0 &&
strlen(value) < ENV_STRING_LENGTH) {
str8to16(data->kernelfile, value);
- VERBOSE(stderr, "kernelfile: %s\n", value);
- } else if (strcmp(key, "kernelparams") == 0 &&
+ VERBOSE(stderr,
+ BG_ENV_KERNELFILE_STRING ": %s\n",
+ value);
+ } else if (strcmp(key, BG_ENV_KERNELPARAMS_STRING) ==
+ 0 &&
strlen(value) < ENV_STRING_LENGTH) {
str8to16(data->kernelparams, value);
- VERBOSE(stderr, "kernelparams: %s\n", value);
- } else if (strcmp(key, "in_progress") == 0) {
+ VERBOSE(stderr,
+ BG_ENV_KERNELPARAMS_STRING ": %s\n",
+ value);
+ } else if (strcmp(key, BG_ENV_IN_PROGRESS_STRING) ==
+ 0) {
data->in_progress = MIN(
strtoul(value, NULL, 10), UINT8_MAX);
- VERBOSE(stdout, "in_progress: %hhu\n",
+ VERBOSE(stdout,
+ BG_ENV_IN_PROGRESS_STRING ": %hhu\n",
data->in_progress);
- } else if (strcmp(key, "ustate") == 0) {
+ } else if (strcmp(key, BG_ENV_USTATE_STRING) == 0) {
data->ustate = MIN(strtoul(value, NULL, 10),
UINT8_MAX);
- VERBOSE(stdout, "ustate: %hhu\n", data->ustate);
- } else if (strcmp(key, "watchdog_timeout_sec") == 0) {
+ VERBOSE(stdout, BG_ENV_USTATE_STRING ": %hhu\n",
+ data->ustate);
+ } else if (strcmp(key,
+ BG_ENV_WATCHDOG_TIMEOUT_SEC_STRING) ==
+ 0) {
data->watchdog_timeout_sec = MIN(
strtoul(value, NULL, 10), UINT16_MAX);
- VERBOSE(stdout, "watchdog_timeout_sec: %hu\n",
+ VERBOSE(stdout,
+ BG_ENV_WATCHDOG_TIMEOUT_SEC_STRING
+ ": %hu\n",
data->watchdog_timeout_sec);
- } else if (strcmp(key, "revision") == 0) {
+ } else if (strcmp(key, BG_ENV_REVISION_STRING) == 0) {
data->revision = strtoul(value, NULL, 0);
- VERBOSE(stdout, "revision: 0x%08lx\n",
+ VERBOSE(stdout,
+ BG_ENV_REVISION_STRING ": 0x%08lx\n",
data->revision);
} else
VERBOSE(stderr, "<unknown>: %s\n", value);
diff --git a/include/envdata.h b/include/envdata.h
index 7c3cfca..acd2a16 100644
--- a/include/envdata.h
+++ b/include/envdata.h
@@ -45,4 +45,12 @@ struct _BG_ENVDATA {
};
#pragma pack(pop)
+#define BG_ENV_KERNELFILE_STRING "kernelfile"
+#define BG_ENV_KERNELPARAMS_STRING "kernelparams"
+#define BG_ENV_IN_PROGRESS_STRING "in_progress"
+#define BG_ENV_USTATE_STRING "ustate"
+#define BG_ENV_WATCHDOG_TIMEOUT_SEC_STRING "watchdog_timeout_sec"
+#define BG_ENV_REVISION_STRING "revision"
+#define BG_ENV_CRC32_STRING "crc32"
+
typedef struct _BG_ENVDATA BG_ENVDATA;
--
2.36.1
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/20220809135300.1470407-5-tobiasschmidl%40siemens.com.