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

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