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