From f69ef81e25d21c401cb68ec061f3959bfce9988a Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phco...@gmail.com>
Date: Thu, 24 Aug 2023 09:33:47 +0200
Subject: [PATCH 03/13] Fix compilation of generic/blocklist

---
 grub-core/osdep/generic/blocklist.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/grub-core/osdep/generic/blocklist.c b/grub-core/osdep/generic/blocklist.c
index 2d9040302..97e416866 100644
--- a/grub-core/osdep/generic/blocklist.c
+++ b/grub-core/osdep/generic/blocklist.c
@@ -30,6 +30,25 @@
 
 #define MAX_TRIES	5
 
+struct wrapper_hook_data
+{
+  void (*callback) (grub_disk_addr_t sector,
+		    unsigned offset,
+		    unsigned length,
+		    void *data);
+  void *callback_data;
+};
+
+static grub_err_t
+callback_wrapper (grub_disk_addr_t sector,
+		  unsigned offset, unsigned length,
+		  char *buf, void *data)
+{
+  struct wrapper_hook_data *wrap = data;
+  wrap->callback(sector, offset, length, wrap->callback_data);
+  return GRUB_ERR_NONE;
+}
+
 void
 grub_install_get_blocklist (grub_device_t root_dev,
 			    const char *core_path, const char *core_img,
@@ -43,6 +62,10 @@ grub_install_get_blocklist (grub_device_t root_dev,
   int i;
   char *tmp_img;
   char *core_path_dev;
+  struct wrapper_hook_data wrap_hook_data = {
+    .callback = callback,
+    .callback_data = hook_data
+  };
 
   core_path_dev = grub_make_system_path_relative_to_its_root (core_path);
 
@@ -120,8 +143,8 @@ grub_install_get_blocklist (grub_device_t root_dev,
   if (! file)
     grub_util_error ("%s", grub_errmsg);
 
-  file->read_hook = callback;
-  file->read_hook_data = hook_data;
+  file->read_hook = callback_wrapper;
+  file->read_hook_data = &wrap_hook_data;
   if (grub_file_read (file, tmp_img, core_size) != (grub_ssize_t) core_size)
     grub_util_error ("%s", _("failed to read the sectors of the core image"));
 
-- 
2.42.0

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to