]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto: remove directory check for ESP mount
authorMichael Ferrari <nekkodroid404@gmail.com>
Tue, 15 Oct 2024 16:42:20 +0000 (18:42 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 16 Oct 2024 01:09:38 +0000 (10:09 +0900)
Ensure that we always attempt to mount the `ESP` partition to `/boot`
when there is no `XBOOTLDR` partition.

Fixes an issue when booting without a `XBOOTLDR` partition and an empty
root partition, since it would mount the `ESP` partition to `/efi/`
unconditionally causing boot entries to not be under `/boot/` as
recommended by the Boot Loader Specification.

src/gpt-auto-generator/gpt-auto-generator.c

index 6f0d7c877a0ec4180888a50599309ed076cdfb06..8bb32afb279ad265d1047ce0ef6f9c06202183ed 100644 (file)
@@ -503,21 +503,6 @@ static int add_partition_xbootldr(DissectedPartition *p) {
 }
 
 #if ENABLE_EFI
-static bool slash_boot_exists(void) {
-        static int cache = -1;
-
-        if (cache >= 0)
-                return cache;
-
-        if (access("/boot", F_OK) >= 0)
-                return (cache = true);
-        if (errno != ENOENT)
-                log_error_errno(errno, "Failed to determine whether /boot/ exists, assuming no: %m");
-        else
-                log_debug_errno(errno, "/boot/: %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;
@@ -538,10 +523,10 @@ static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) {
         if (r > 0)
                 return 0;
 
-        /* If /boot/ is present, unused, and empty, we'll take that.
+        /* If XBOOTLDR partition is not present and /boot/ is 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()) {
+        if (!has_xbootldr) {
                 r = path_is_busy("/boot");
                 if (r < 0)
                         return r;