5593c8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5593c8
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
5593c8
Date: Fri, 29 Nov 2019 11:02:00 +0100
5593c8
Subject: [PATCH] grub_file_* instrumentation (new 'file' debug tag)
5593c8
MIME-Version: 1.0
5593c8
Content-Type: text/plain; charset=UTF-8
5593c8
Content-Transfer-Encoding: 8bit
5593c8
5593c8
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
5593c8
---
5593c8
 grub-core/kern/file.c | 14 ++++++++++++++
5593c8
 1 file changed, 14 insertions(+)
5593c8
5593c8
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
fd0330
index 5b58f45cfd..ec10e54fc0 100644
5593c8
--- a/grub-core/kern/file.c
5593c8
+++ b/grub-core/kern/file.c
5593c8
@@ -66,6 +66,8 @@ grub_file_open (const char *name, enum grub_file_type type)
5593c8
   const char *file_name;
5593c8
   grub_file_filter_id_t filter;
5593c8
 
5593c8
+  grub_dprintf ("file", "Opening `%s' ...\n", name);
5593c8
+
fd0330
   /* Reset grub_errno before we start */
fd0330
   grub_errno = GRUB_ERR_NONE;
fd0330
 
fd0330
@@ -131,6 +133,8 @@ grub_file_open (const char *name, enum grub_file_type type)
5593c8
   if (!file)
5593c8
     grub_file_close (last_file);
5593c8
 
5593c8
+  grub_dprintf ("file", "Opening `%s' succeeded.\n", name);
5593c8
+
5593c8
   return file;
5593c8
 
5593c8
  fail:
fd0330
@@ -141,6 +145,8 @@ grub_file_open (const char *name, enum grub_file_type type)
5593c8
 
5593c8
   grub_free (file);
5593c8
 
5593c8
+  grub_dprintf ("file", "Opening `%s' failed.\n", name);
5593c8
+
5593c8
   return 0;
5593c8
 }
5593c8
 
fd0330
@@ -172,6 +178,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
5593c8
 
5593c8
   if (len == 0)
5593c8
     return 0;
5593c8
+
5593c8
   read_hook = file->read_hook;
5593c8
   read_hook_data = file->read_hook_data;
5593c8
   if (!file->read_hook)
fd0330
@@ -192,11 +199,18 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
5593c8
 grub_err_t
5593c8
 grub_file_close (grub_file_t file)
5593c8
 {
5593c8
+  grub_dprintf ("file", "Closing `%s' ...\n", file->name);
5593c8
   if (file->fs->fs_close)
5593c8
     (file->fs->fs_close) (file);
5593c8
 
5593c8
   if (file->device)
5593c8
     grub_device_close (file->device);
5593c8
+
5593c8
+  if (grub_errno == GRUB_ERR_NONE)
5593c8
+    grub_dprintf ("file", "Closing `%s' succeeded.\n", file->name);
5593c8
+  else
5593c8
+    grub_dprintf ("file", "Closing `%s' failed with %d.\n", file->name, grub_errno);
5593c8
+
5593c8
   grub_free (file->name);
5593c8
   grub_free (file);
5593c8
   return grub_errno;