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

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