]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_write) [__linux__]:
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 2 Jun 2012 11:48:44 +0000 (13:48 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 2 Jun 2012 11:48:44 +0000 (13:48 +0200)
Fix MBR remapping workaround.
(grub_util_biosdisk_read) [__linux__]: Likewise.

ChangeLog
grub-core/kern/emu/hostdisk.c

index 54eea4ab75a929f1ed7640bc4dd5d7ef3f25efbf..cccffb5478c971c14c4fb082528c1ce426c47e8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-02  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_write) [__linux__]:
+       Fix MBR remapping workaround.
+       (grub_util_biosdisk_read) [__linux__]: Likewise.
+
 2012-06-01  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * util/grub-install.in: Check for ieee1275 and not ieee1276.
index 772df26ee18e9550a3c26cba3f37fa3ef7b42fbe..9831151270112417f42f83fb072b46e273a52b3b 100644 (file)
@@ -1067,27 +1067,18 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
       if (fd < 0)
        return grub_errno;
 
-      if (max > size)
-       max = size;
-
 #ifdef __linux__
-      if (sector == 0 && max > 1)
-       {
-         /* Work around a bug in Linux ez remapping.  Linux remaps all
-            sectors that are read together with the MBR in one read.  It
-            should only remap the MBR, so we split the read in two
-            parts. -jochen  */
-         if (grub_util_fd_read (fd, buf, (1 << disk->log_sector_size))
-             != (1 << disk->log_sector_size))
-           return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
-                              map[disk->id].device, strerror (errno));
-         
-         buf += (1 << disk->log_sector_size);
-         size--;
-         max--;
-       }
+      if (sector == 0)
+       /* Work around a bug in Linux ez remapping.  Linux remaps all
+          sectors that are read together with the MBR in one read.  It
+          should only remap the MBR, so we split the read in two
+          parts. -jochen  */
+       max = 1;
 #endif /* __linux__ */
 
+      if (max > size)
+       max = size;
+
       if (grub_util_fd_read (fd, buf, max << disk->log_sector_size)
          != (ssize_t) (max << disk->log_sector_size))
        return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
@@ -1111,28 +1102,18 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
       if (fd < 0)
        return grub_errno;
 
-      if (max > size)
-       max = size;
-
 #ifdef __linux__
-      if (sector == 0 && max > 1)
-       {
-         /* Work around a bug in Linux ez remapping.  Linux remaps all
-            sectors that are write together with the MBR in one write.  It
-            should only remap the MBR, so we split the write in two
-            parts. -jochen  */
-         if (grub_util_fd_write (fd, buf, (1 << disk->log_sector_size))
-             != (1 << disk->log_sector_size))
-           return grub_error (GRUB_ERR_WRITE_ERROR,
-                              N_("cannot write to `%s': %s"),
-                              map[disk->id].device, strerror (errno));
-         
-         buf += (1 << disk->log_sector_size);
-         size--;
-         max--;
-       }
+      if (sector == 0)
+       /* Work around a bug in Linux ez remapping.  Linux remaps all
+          sectors that are write together with the MBR in one write.  It
+          should only remap the MBR, so we split the write in two
+          parts. -jochen  */
+       max = 1;
 #endif /* __linux__ */
 
+      if (max > size)
+       max = size;
+
       if (grub_util_fd_write (fd, buf, max << disk->log_sector_size)
          != (ssize_t) (max << disk->log_sector_size))
        return grub_error (GRUB_ERR_WRITE_ERROR, N_("cannot write to `%s': %s"),