From e91e48f811da5e8a32a7b8ceb81b46118ebb6e05 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Fri, 8 Dec 2023 03:10:10 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20utils:=20add=20helper=20function?= =?UTF-8?q?=20to=20get=20default=20mountpoint=20for=20bootloader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils.hpp b/src/utils.hpp index f521ad3..0a4b0c8 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -113,6 +113,18 @@ constexpr inline double convert_unit(const double number, const std::string_view return number; } +// Get appropriate default mountpoint for bootloader +constexpr inline auto bootloader_default_mount(std::string_view bootloader, std::string_view bios_mode) noexcept -> std::string_view { + using namespace std::string_view_literals; + + if (bootloader == "systemd-boot"sv || bios_mode == "BIOS"sv) { + return "/boot"sv; + } else if (bootloader == "grub"sv || bootloader == "refind"sv) { + return "/boot/efi"sv; + } + return "unknown bootloader"sv; +} + } // namespace utils #endif // UTILS_HPP