* grub-core/disk/efi/efidisk.c: Limit disk read or write chunk to 0x500

sectors.
	Based on patch by Peter Jones.
This commit is contained in:
Peter Jones 2013-04-15 09:12:14 +02:00 committed by Vladimir 'phcoder' Serbinenko
parent 25fc51a879
commit a7e03923fa
2 changed files with 40 additions and 17 deletions

View file

@ -1,3 +1,10 @@
2013-04-15 Vladimir Serbinenko <phcoder@gmail.com>
2013-04-15 Peter Jones <pjones@redhat.com>
* grub-core/disk/efi/efidisk.c: Limit disk read or write chunk to 0x500
sectors.
Based on patch by Peter Jones.
2013-04-15 Vladimir Serbinenko <phcoder@gmail.com>
Fix DMRAID partition handling.

View file

@ -528,9 +528,9 @@ grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused)))
grub_dprintf ("efidisk", "closing %s\n", disk->name);
}
static grub_err_t
grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
static grub_efi_status_t
grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf, int wr)
{
/* For now, use the disk io interface rather than the block io's. */
struct grub_efidisk_data *d;
@ -540,14 +540,38 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
d = disk->data;
bio = d->block_io;
while (size > 0)
{
grub_size_t len;
len = 0x500;
if (len > size)
len = size;
status = efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio,
bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) size << disk->log_sector_size,
buf);
size -= len;
buf += len << disk->log_sector_size;
sector += len;
if (status != GRUB_EFI_SUCCESS)
return status;
}
return GRUB_EFI_SUCCESS;
}
static grub_err_t
grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_efi_status_t status;
grub_dprintf ("efidisk",
"reading 0x%lx sectors at the sector 0x%llx from %s\n",
(unsigned long) size, (unsigned long long) sector, disk->name);
status = efi_call_5 (bio->read_blocks, bio, bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) size << disk->log_sector_size,
buf);
status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_READ_ERROR,
N_("failure reading sector 0x%llx from `%s'"),
@ -561,22 +585,14 @@ static grub_err_t
grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
/* For now, use the disk io interface rather than the block io's. */
struct grub_efidisk_data *d;
grub_efi_block_io_t *bio;
grub_efi_status_t status;
d = disk->data;
bio = d->block_io;
grub_dprintf ("efidisk",
"writing 0x%lx sectors at the sector 0x%llx to %s\n",
(unsigned long) size, (unsigned long long) sector, disk->name);
status = efi_call_5 (bio->write_blocks, bio, bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) size << disk->log_sector_size,
(void *) buf);
status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_WRITE_ERROR,
N_("failure writing sector 0x%llx to `%s'"),