From 1ed52ffd389d28a8c1711fedcd9a841258c30e28 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Jan 2013 08:09:26 +0100 Subject: [PATCH 091/364] * 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 + + * 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 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.1.4