Skip to content

Commit

Permalink
src/bootchooser: introduce r_boot_is_supported_bootloader()
Browse files Browse the repository at this point in the history
The information which bootloader is supported should be provided by
the bootchooser module that also implements the support, not by the
config_file module that is responsible only for parsing.

Thus we move the definition of supported bootloaders there and
encapsulate checking implementation by a transparent checker method
r_boot_is_supported_bootloader().

Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Jul 23, 2021
1 parent 2bb06a5 commit 3b635d1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions include/bootchooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ GQuark r_bootchooser_error_quark(void);
#define R_BOOTCHOOSER_ERROR_NOT_SUPPORTED 10
#define R_BOOTCHOOSER_ERROR_PARSE_FAILED 20

/**
* Check if bootloader (name) is supported
*
* @param typename Name of bootloader as represented in config
*
* @return TRUE if it is supported, otherwise FALSE
*/
gboolean r_boot_is_supported_bootloader(const gchar *bootloader)
G_GNUC_WARN_UNUSED_RESULT;

/**
* Mark slot as good or bad.
*
Expand Down
7 changes: 7 additions & 0 deletions src/bootchooser.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ GQuark r_bootchooser_error_quark(void)
#define EFIBOOTMGR_NAME "efibootmgr"
#define GRUB_EDITENV "grub-editenv"

static const gchar *supported_bootloaders[] = {"barebox", "grub", "uboot", "efi", "custom", "noop", NULL};

gboolean r_boot_is_supported_bootloader(const gchar *bootloader)
{
return g_strv_contains(supported_bootloaders, bootloader);
}

static GString *bootchooser_order_primay(RaucSlot *slot)
{
GString *order = NULL;
Expand Down
5 changes: 2 additions & 3 deletions src/config_file.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <glib.h>
#include <string.h>

#include "bootchooser.h"
#include "config_file.h"
#include "context.h"
#include "manifest.h"
Expand Down Expand Up @@ -70,8 +71,6 @@ static gboolean fix_grandparent_links(GHashTable *slots, GError **error)
return TRUE;
}

static const gchar *supported_bootloaders[] = {"barebox", "grub", "uboot", "efi", "custom", "noop", NULL};

gboolean parse_bundle_formats(guint *mask, const gchar *config, GError **error)
{
gboolean res = TRUE;
Expand Down Expand Up @@ -197,7 +196,7 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
goto free;
}

if (!g_strv_contains(supported_bootloaders, c->system_bootloader)) {
if (!r_boot_is_supported_bootloader(c->system_bootloader)) {
g_set_error(
error,
R_CONFIG_ERROR,
Expand Down

0 comments on commit 3b635d1

Please sign in to comment.