--- systemd-stable-254.1/src/gpt-auto-generator/gpt-auto-generator.c.orig 2023-08-09 22:33:59.978475054 +0200 +++ systemd-stable-254.1/src/gpt-auto-generator/gpt-auto-generator.c 2023-08-09 22:41:09.618936068 +0200 @@ -487,6 +487,18 @@ return cache; } +static int slash_boot_efi_in_fstab(void) { + static int cache = -1; + + if (cache >= 0) + return cache; + + cache = fstab_is_mount_point("/boot/efi"); + if (cache < 0) + return log_error_errno(cache, "Failed to parse fstab: %m"); + return cache; +} + static int add_partition_xbootldr(DissectedPartition *p) { _cleanup_free_ char *options = NULL; int r; @@ -562,6 +574,21 @@ return (cache = false); } +static bool slash_boot_efi_exists(void) { + static int cache = -1; + + if (cache >= 0) + return cache; + + if (access("/boot/efi", F_OK) >= 0) + return (cache = true); + if (errno != ENOENT) + log_error_errno(errno, "Failed to determine whether /boot/efi exists, assuming no: %m"); + else + log_debug_errno(errno, "/boot/efi: %m"); + return (cache = false); +} + static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) { const char *esp_path = NULL, *id = NULL; _cleanup_free_ char *options = NULL; @@ -582,19 +609,19 @@ if (r > 0) return 0; - /* If /boot/ is present, unused, and empty, we'll take that. + /* If /boot/efi is present, unused, and empty, we'll take that. * Otherwise, if /efi/ is unused and empty (or missing), we'll take that. * Otherwise, we do nothing. */ - if (!has_xbootldr && slash_boot_exists()) { - r = slash_boot_in_fstab(); + if (!has_xbootldr && slash_boot_efi_exists()) { + r = slash_boot_efi_in_fstab(); if (r < 0) return r; if (r == 0) { - r = path_is_busy("/boot"); + r = path_is_busy("/boot/efi"); if (r < 0) return r; if (r == 0) { - esp_path = "/boot"; + esp_path = "/boot/efi"; id = "boot"; } }