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

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