Blame SOURCES/0555-Make-debug-file-show-which-file-filters-get-run.patch

c6c771
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
c6c771
From: Peter Jones <pjones@redhat.com>
c6c771
Date: Fri, 29 Jul 2022 15:56:00 -0400
c6c771
Subject: [PATCH] Make debug=file show which file filters get run.
c6c771
c6c771
If one of the file filters breaks things, it's hard to figure out where
c6c771
it has happened.
c6c771
c6c771
This makes grub log which filter is being run, which makes it easier to
c6c771
figure out where you are in the sequence of events.
c6c771
c6c771
Signed-off-by: Peter Jones <pjones@redhat.com>
c6c771
(cherry picked from commit d3d6518a13b5440a3be6c66b0ae47447182f2891)
c6c771
(cherry picked from commit d197e70761b1383827e9008e21ee41c6c7015776)
c6c771
---
c6c771
 grub-core/kern/file.c | 11 +++++++++++
c6c771
 1 file changed, 11 insertions(+)
c6c771
c6c771
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
c6c771
index f062fc21e7..5e1f29d0dd 100644
c6c771
--- a/grub-core/kern/file.c
c6c771
+++ b/grub-core/kern/file.c
c6c771
@@ -30,6 +30,14 @@ void (*EXPORT_VAR (grub_grubnet_fini)) (void);
c6c771
 
c6c771
 grub_file_filter_t grub_file_filters[GRUB_FILE_FILTER_MAX];
c6c771
 
c6c771
+static char *filter_names[] = {
c6c771
+    [GRUB_FILE_FILTER_VERIFY] = "GRUB_FILE_FILTER_VERIFY",
c6c771
+    [GRUB_FILE_FILTER_GZIO] = "GRUB_FILE_FILTER_GZIO",
c6c771
+    [GRUB_FILE_FILTER_XZIO] = "GRUB_FILE_FILTER_XZIO",
c6c771
+    [GRUB_FILE_FILTER_LZOPIO] = "GRUB_FILE_FILTER_LZOPIO",
c6c771
+    [GRUB_FILE_FILTER_MAX] = "GRUB_FILE_FILTER_MAX"
c6c771
+};
c6c771
+
c6c771
 /* Get the device part of the filename NAME. It is enclosed by parentheses.  */
c6c771
 char *
c6c771
 grub_file_get_device_name (const char *name)
c6c771
@@ -121,6 +129,9 @@ grub_file_open (const char *name, enum grub_file_type type)
c6c771
     if (grub_file_filters[filter])
c6c771
       {
c6c771
 	last_file = file;
c6c771
+	if (filter < GRUB_FILE_FILTER_MAX)
c6c771
+	  grub_dprintf ("file", "Running %s file filter\n",
c6c771
+			filter_names[filter]);
c6c771
 	file = grub_file_filters[filter] (file, type);
c6c771
 	if (file && file != last_file)
c6c771
 	  {