3ad78fd
From f923381741b5a56115c5860a593e94539c5bbc8f Mon Sep 17 00:00:00 2001
3ad78fd
From: Peter Jones <pjones@redhat.com>
3ad78fd
Date: Wed, 3 Apr 2013 11:41:52 -0400
3ad78fd
Subject: [PATCH] Make grub_efidisk_get_device_name() work on 4K native disks.
3ad78fd
3ad78fd
When we have 4kB sectors instead of 512b sectors, hd.partition_start and
3ad78fd
grub_partition_get_start() won't match - the latter assumes 512-byte
3ad78fd
sectors, and the former gives us the correct number based on the
3ad78fd
physical media's sector size.  So when we have to compare them, we need
3ad78fd
to compensate.
3ad78fd
3ad78fd
Signed-off-by: Peter Jones <grub2-owner@fedoraproject.org>
3ad78fd
---
3ad78fd
 grub-core/disk/efi/efidisk.c | 10 ++++++----
3ad78fd
 1 file changed, 6 insertions(+), 4 deletions(-)
3ad78fd
3ad78fd
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
3ad78fd
index 77ab5b0..a905b52 100644
3ad78fd
--- a/grub-core/disk/efi/efidisk.c
3ad78fd
+++ b/grub-core/disk/efi/efidisk.c
3ad78fd
@@ -791,11 +791,13 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
3ad78fd
       auto int find_partition (grub_disk_t disk, const grub_partition_t part);
3ad78fd
 
3ad78fd
       /* Find the identical partition.  */
3ad78fd
-      int find_partition (grub_disk_t disk __attribute__ ((unused)),
3ad78fd
-			  const grub_partition_t part)
3ad78fd
+      int find_partition (grub_disk_t disk, const grub_partition_t part)
3ad78fd
 	{
3ad78fd
-	  if (grub_partition_get_start (part) == hd.partition_start
3ad78fd
-	      && grub_partition_get_len (part) == hd.partition_size)
3ad78fd
+	  struct grub_efidisk_data *d = disk->data;
3ad78fd
+	  grub_efi_block_io_media_t *m = d->block_io->media;
3ad78fd
+
3ad78fd
+	  if (grub_partition_get_start (part) / (m->block_size / 512) == hd.partition_start
3ad78fd
+	      && grub_partition_get_len (part) / (m->block_size / 512) == hd.partition_size)
3ad78fd
 	    {
3ad78fd
 	      partition_name = grub_partition_get_name (part);
3ad78fd
 	      return 1;
3ad78fd
-- 
3ad78fd
1.8.1.4
3ad78fd