From 4dedb13f51bd467f00a2da9c3611f7c00519f889 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Jan 2013 08:09:26 +0100 Subject: [PATCH] * 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 75fb85a3c..48d297d8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-01-10 Vladimir Serbinenko + + * grub-core/kern/disk.c (grub_disk_write): Fix sector number on 4K + sector devices. + 2013-01-07 Colin Watson * 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 1f55f90a8..94318af32 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;