Blame SOURCES/0210-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Javier Martinez Canillas <javierm@redhat.com>
8631a2
Date: Wed, 18 Jul 2018 08:08:06 +0200
8631a2
Subject: [PATCH] blscfg: Fallback to search BLS snippets in
8631a2
 /boot/loader/entries
8631a2
8631a2
The default path to search the BLS snippets is /loader/entries, this is
8631a2
only a correct assumption if $root ($root) is a boot partition but it's
8631a2
not true if /boot isn't a mount point.
8631a2
8631a2
A user can set a blsdir grub environment variable to choose a different
8631a2
path, but instead of failing when /boot is a directory inside the root
8631a2
partition fallback to search the BLS in /boot/loader/entries to cover
8631a2
that case as well.
8631a2
8631a2
Reported-by: Hans de Goede <hdegoede@redhat.com>
8631a2
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
8631a2
---
8631a2
 grub-core/commands/blscfg.c | 13 ++++++++++++-
8631a2
 1 file changed, 12 insertions(+), 1 deletion(-)
8631a2
8631a2
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
8631a2
index 80d8814fc3f..321c93069f2 100644
8631a2
--- a/grub-core/commands/blscfg.c
8631a2
+++ b/grub-core/commands/blscfg.c
8631a2
@@ -692,6 +692,7 @@ static int find_entry (const char *filename,
8631a2
   grub_device_t blsdir_dev = NULL;
8631a2
   const char *blsdir = NULL;
8631a2
   char *saved_env_buf = NULL;
8631a2
+  int fallback = 0;
8631a2
   int r = 0;
8631a2
   const char *devid = grub_env_get ("boot");
8631a2
 
8631a2
@@ -797,7 +798,9 @@ static int find_entry (const char *filename,
8631a2
   }
8631a2
   read_entry_info.dirname = blsdir;
8631a2
 
8631a2
-  r = blsdir_fs->dir (blsdir_dev, blsdir, read_entry, &read_entry_info);
8631a2
+read_fallback:
8631a2
+  r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry,
8631a2
+		      &read_entry_info);
8631a2
   if (r != 0) {
8631a2
       grub_dprintf ("blscfg", "read_entry returned error\n");
8631a2
       grub_err_t e;
8631a2
@@ -807,6 +810,14 @@ static int find_entry (const char *filename,
8631a2
 	} while (e);
8631a2
   }
8631a2
 
8631a2
+  if (!nentries && !fallback && info->platform != PLATFORM_EMU) {
8631a2
+    read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH;
8631a2
+    grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n",
8631a2
+		  blsdir, read_entry_info.dirname);
8631a2
+    fallback = 1;
8631a2
+    goto read_fallback;
8631a2
+  }
8631a2
+
8631a2
   grub_dprintf ("blscfg", "Sorting %d entries\n", nentries);
8631a2
   grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL);
8631a2