a5bd9f
From 9c5d1aa956de89b429997b19e20cdd887f612414 Mon Sep 17 00:00:00 2001
a5bd9f
From: Peter Jones <pjones@redhat.com>
a5bd9f
Date: Thu, 4 Apr 2013 10:35:50 +0200
a5bd9f
Subject: [PATCH 253/364] 	* grub-core/disk/efi/efidisk.c: Handle
a5bd9f
 partitions on non-512B disks.
a5bd9f
a5bd9f
---
a5bd9f
 ChangeLog                    |  5 +++++
a5bd9f
 grub-core/disk/efi/efidisk.c | 20 ++++++++++++++------
a5bd9f
 2 files changed, 19 insertions(+), 6 deletions(-)
a5bd9f
a5bd9f
diff --git a/ChangeLog b/ChangeLog
a5bd9f
index bd9e903..400a071 100644
a5bd9f
--- a/ChangeLog
a5bd9f
+++ b/ChangeLog
a5bd9f
@@ -1,4 +1,9 @@
a5bd9f
 2013-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f
+2013-04-04  Peter Jones <pjones@redhat.com>
a5bd9f
+
a5bd9f
+	* grub-core/disk/efi/efidisk.c: Handle partitions on non-512B disks.
a5bd9f
+
a5bd9f
+2013-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f
 
a5bd9f
 	Use TSC as a possible time source on i386-ieee1275.
a5bd9f
 
a5bd9f
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
a5bd9f
index c883b2c..0a364f1 100644
a5bd9f
--- a/grub-core/disk/efi/efidisk.c
a5bd9f
+++ b/grub-core/disk/efi/efidisk.c
a5bd9f
@@ -658,10 +658,12 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
a5bd9f
 		 == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
a5bd9f
 		&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
a5bd9f
 		    == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
a5bd9f
-		&& (grub_partition_get_start (disk->partition)
a5bd9f
-		    == hd.partition_start)
a5bd9f
+		&& (grub_partition_get_start (disk->partition) 
a5bd9f
+		    == (hd.partition_start << (disk->log_sector_size
a5bd9f
+					       - GRUB_DISK_SECTOR_BITS)))
a5bd9f
 		&& (grub_partition_get_len (disk->partition)
a5bd9f
-		    == hd.partition_size))
a5bd9f
+		    == (hd.partition_size << (disk->log_sector_size
a5bd9f
+					      - GRUB_DISK_SECTOR_BITS))))
a5bd9f
 	      {
a5bd9f
 		handle = c->handle;
a5bd9f
 		break;
a5bd9f
@@ -738,8 +740,12 @@ grub_efidisk_get_device_name_iter (grub_disk_t disk __attribute__ ((unused)),
a5bd9f
 {
a5bd9f
   struct grub_efidisk_get_device_name_ctx *ctx = data;
a5bd9f
 
a5bd9f
-  if (grub_partition_get_start (part) == ctx->hd.partition_start
a5bd9f
-      && grub_partition_get_len (part) == ctx->hd.partition_size)
a5bd9f
+  if (grub_partition_get_start (part)
a5bd9f
+      == (ctx->hd.partition_start << (disk->log_sector_size
a5bd9f
+				      - GRUB_DISK_SECTOR_BITS))
a5bd9f
+      && grub_partition_get_len (part)
a5bd9f
+      == (ctx->hd.partition_size << (disk->log_sector_size
a5bd9f
+				     - GRUB_DISK_SECTOR_BITS)))
a5bd9f
     {
a5bd9f
       ctx->partition_name = grub_partition_get_name (part);
a5bd9f
       return 1;
a5bd9f
@@ -798,7 +804,9 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
a5bd9f
       ctx.partition_name = NULL;
a5bd9f
       grub_memcpy (&ctx.hd, ldp, sizeof (ctx.hd));
a5bd9f
       if (ctx.hd.partition_start == 0
a5bd9f
-	  && ctx.hd.partition_size == grub_disk_get_size (parent))
a5bd9f
+	  && (ctx.hd.partition_size << (parent->log_sector_size
a5bd9f
+					- GRUB_DISK_SECTOR_BITS))
a5bd9f
+	      == grub_disk_get_size (parent))
a5bd9f
 	{
a5bd9f
 	  dev_name = grub_strdup (parent->name);
a5bd9f
 	}
a5bd9f
-- 
a5bd9f
1.8.1.4
a5bd9f