grub2/0092-grub-core-kern-disk.c-grub_disk_write-Fix-sector-num.patch
Peter Jones f74b50e380 Rebase to upstream, fix a pile of bugs. The usual.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-06-12 15:37:08 -04:00

60 lines
2.0 KiB
Diff

From 2aa6a4fce53d2a43cc00fde2362eb39d1fdb9f4d Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Thu, 10 Jan 2013 08:09:26 +0100
Subject: [PATCH 092/482] * grub-core/kern/disk.c (grub_disk_write): Fix
sector number on 4K sector devices.
---
ChangeLog | 5 +++++
grub-core/kern/disk.c | 11 ++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 75fb85a..48d297d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-01-10 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/disk.c (grub_disk_write): Fix sector number on 4K
+ sector devices.
+
2013-01-07 Colin Watson <cjwatson@ubuntu.com>
* grub-core/io/bufio.c (grub_bufio_open): Use grub_zalloc instead of
diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c
index 1f55f90..94318af 100644
--- a/grub-core/kern/disk.c
+++ b/grub-core/kern/disk.c
@@ -658,7 +658,8 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_disk_cache_invalidate (disk->dev->id, disk->id, sector);
- if ((disk->dev->write) (disk, sector, 1, tmp_buf) != GRUB_ERR_NONE)
+ if ((disk->dev->write) (disk, transform_sector (disk, sector),
+ 1, tmp_buf) != GRUB_ERR_NONE)
goto finish;
sector += (1 << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
@@ -674,11 +675,15 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
len = size & ~((1 << disk->log_sector_size) - 1);
n = size >> disk->log_sector_size;
- if ((disk->dev->write) (disk, sector, n, buf) != GRUB_ERR_NONE)
+ if ((disk->dev->write) (disk, transform_sector (disk, sector),
+ n, buf) != GRUB_ERR_NONE)
goto finish;
while (n--)
- grub_disk_cache_invalidate (disk->dev->id, disk->id, sector++);
+ {
+ grub_disk_cache_invalidate (disk->dev->id, disk->id, sector);
+ sector += (1 << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ }
buf = (const char *) buf + len;
size -= len;
--
1.8.2.1