]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep/generic/blocklist: Fix compilation
authorVladimir Serbinenko <phcoder@gmail.com>
Thu, 24 Aug 2023 07:33:47 +0000 (09:33 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 12 Dec 2023 16:53:56 +0000 (17:53 +0100)
After recent change in blocklist types we have a type mismatch. Fixing it
requires a wrapper or large changes. I feel like wrapper makes more sense.

Without this patch we end up with a compilation problem and without wrapping
callback data is not passed properly anymore.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/osdep/generic/blocklist.c

index 2d904030206d8dd2c60098b1f86a7a8091cedcfc..9ff8e44c62f6b70dfe55101fbc7a0bbe63487865 100644 (file)
 
 #define MAX_TRIES      5
 
+struct wrapper_hook_data
+{
+  void (*callback) (grub_disk_addr_t sector,
+                   unsigned int offset,
+                   unsigned int length,
+                   void *data);
+  void *callback_data;
+};
+
+static grub_err_t
+callback_wrapper (grub_disk_addr_t sector,
+                 unsigned int offset, unsigned int 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 +63,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 +144,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"));