From f7351723e1928e6e8793e79dede7ca4e139bac98 Mon Sep 17 00:00:00 2001 From: Silke Hofstra Date: Wed, 30 Dec 2020 19:38:22 +0100 Subject: [PATCH] bootman: only do partitionless boot when the bootloader supports it #174 restored support for partitionless /boot. However, this introduced issues when (for whatever reason) there is content in the /boot directory (instead of being empty) (see #175). As partitionless boot is not an option for every bootloader, add a flag indication bootloader support. Bootloaders without partitionless support (and those on UEFI) will never try to use a partitionless /boot. --- src/bootloaders/bootloader.h | 13 +++++++------ src/bootloaders/extlinux.c | 3 ++- src/bootloaders/grub2.c | 2 +- src/bootloaders/syslinux.c | 3 ++- src/bootman/bootman.c | 13 ++++++++++--- src/bootman/bootman_private.h | 9 +++++++++ 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/bootloaders/bootloader.h b/src/bootloaders/bootloader.h index 00dd1e5c..63c6f725 100644 --- a/src/bootloaders/bootloader.h +++ b/src/bootloaders/bootloader.h @@ -35,12 +35,13 @@ typedef int (*boot_loader_caps)(const BootManager *); typedef enum { BOOTLOADER_CAP_MIN = 1 << 0, - BOOTLOADER_CAP_UEFI = 1 << 1, /**update_efi_vars; } +bool check_partitionless_boot(const BootManager *self, const char *boot_dir) +{ + assert(self != NULL); + return ((self->bootloader->get_capabilities(self) & BOOTLOADER_CAP_PARTLESS) + && !(self->sysconfig->wanted_boot_mask & BOOTLOADER_CAP_UEFI) + && !cbm_is_dir_empty(boot_dir)); +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * diff --git a/src/bootman/bootman_private.h b/src/bootman/bootman_private.h index 38df20b7..50745304 100644 --- a/src/bootman/bootman_private.h +++ b/src/bootman/bootman_private.h @@ -82,6 +82,15 @@ int kernel_compare_reverse(const void *a, const void *b); */ const char *cbm_get_fstype_name(const char *boot_device); +/** + * Check if the system supports a "partitionless" (the system has no /boot partition) boot. + * Conditions are: + * - The bootloader supports this. + * - The system is not UEFI. + * - The /boot folder is not empty. + */ +bool check_partitionless_boot(const BootManager *self, const char *boot_dir); + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html *