From: Andreas Reichel <[email protected]> Add a helper function to the API which should be called in the end of update processes. The function sets in_progress to 0 and ustate to INSTALLED.
Signed-off-by: Andreas Reichel <[email protected]> --- env/env_api.c | 9 +++++++++ include/ebgenv.h | 6 ++++++ tools/tests/test_ebgenv_api.c | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/env/env_api.c b/env/env_api.c index c23b25c..84fd4f4 100644 --- a/env/env_api.c +++ b/env/env_api.c @@ -235,3 +235,12 @@ int ebg_env_close(ebgenv_t *e) e->bgenv = NULL; return 0; } + +int ebg_env_finalize_update(ebgenv_t *e) { + if (!e->bgenv || !((BGENV *)e->bgenv)->data) { + return EIO; + } + ((BGENV *)e->bgenv)->data->in_progress = 0; + ((BGENV *)e->bgenv)->data->ustate = USTATE_INSTALLED; + return 0; +} diff --git a/include/ebgenv.h b/include/ebgenv.h index d33c0d6..12b778e 100644 --- a/include/ebgenv.h +++ b/include/ebgenv.h @@ -128,4 +128,10 @@ int ebg_env_setglobalstate(ebgenv_t *e, uint16_t ustate); */ int ebg_env_close(ebgenv_t *e); +/** @brief Finalizes a currently running update procedure + * @param e A pointer to an ebgenv_t context. + * @return 0 on success, errno on failure + */ +int ebg_env_finalize_update(ebgenv_t *e); + #endif //__EBGENV_H__ diff --git a/tools/tests/test_ebgenv_api.c b/tools/tests/test_ebgenv_api.c index f9ab55c..533b50b 100644 --- a/tools/tests/test_ebgenv_api.c +++ b/tools/tests/test_ebgenv_api.c @@ -150,6 +150,12 @@ START_TEST(ebgenv_api_ebg_env_create_new) ck_assert_int_eq(((BGENV *)e.bgenv)->data->ustate, USTATE_OK); ck_assert_int_eq( ((BGENV *)e.bgenv)->data->revision, ENV_NUM_CONFIG_PARTS+1); + + ret = ebg_env_finalize_update(&e); + + ck_assert_int_eq(ret, 0); + ck_assert_int_eq(((BGENV *)e.bgenv)->data->ustate, USTATE_INSTALLED); + ck_assert_int_eq(((BGENV *)e.bgenv)->data->in_progress, 0); } END_TEST -- 2.15.0 -- 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/20171122115942.960-6-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
