2010-02-03 Vladimir Serbinenko <phcoder@gmail.com>
* util/hostdisk.c (open_device): Don't use partition device when reading before the partition. (grub_util_biosdisk_read): Don't read from partition and before the partition in single operation. (grub_util_biosdisk_write): Don't write to partition and before the partition in single operation.
This commit is contained in:
parent
399f6e4d9c
commit
2b4068e992
2 changed files with 45 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2010-02-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/hostdisk.c (open_device): Don't use partition device when reading
|
||||
before the partition.
|
||||
(grub_util_biosdisk_read): Don't read from partition and before the
|
||||
partition in single operation.
|
||||
(grub_util_biosdisk_write): Don't write to partition and before the
|
||||
partition in single operation.
|
||||
|
||||
2010-02-03 Torsten Landschoff <torsten@debian.org>
|
||||
|
||||
* kern/disk.c (grub_disk_read): Fix offset computation when reading
|
||||
|
|
|
@ -336,7 +336,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
|
|||
char dev[PATH_MAX];
|
||||
|
||||
strcpy (dev, map[disk->id].device);
|
||||
if (disk->partition && strncmp (map[disk->id].device, "/dev/", 5) == 0)
|
||||
if (disk->partition && sector >= disk->partition->start
|
||||
&& strncmp (map[disk->id].device, "/dev/", 5) == 0)
|
||||
is_partition = linux_find_partition (dev, disk->partition->start);
|
||||
|
||||
/* Open the partition. */
|
||||
|
@ -490,6 +491,23 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
{
|
||||
int fd;
|
||||
|
||||
/* Split pre-partition and partition reads. */
|
||||
if (disk->partition && sector < disk->partition->start
|
||||
&& sector + size > disk->partition->start)
|
||||
{
|
||||
grub_err_t err;
|
||||
err = grub_util_biosdisk_read (disk, sector,
|
||||
disk->partition->start - sector,
|
||||
buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return grub_util_biosdisk_read (disk, disk->partition->start,
|
||||
size - (disk->partition->start - sector),
|
||||
buf + ((disk->partition->start - sector)
|
||||
<< GRUB_DISK_SECTOR_BITS));
|
||||
}
|
||||
|
||||
fd = open_device (disk, sector, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return grub_errno;
|
||||
|
@ -527,6 +545,23 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
{
|
||||
int fd;
|
||||
|
||||
/* Split pre-partition and partition writes. */
|
||||
if (disk->partition && sector < disk->partition->start
|
||||
&& sector + size > disk->partition->start)
|
||||
{
|
||||
grub_err_t err;
|
||||
err = grub_util_biosdisk_write (disk, sector,
|
||||
disk->partition->start - sector,
|
||||
buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return grub_util_biosdisk_write (disk, disk->partition->start,
|
||||
size - (disk->partition->start - sector),
|
||||
buf + ((disk->partition->start - sector)
|
||||
<< GRUB_DISK_SECTOR_BITS));
|
||||
}
|
||||
|
||||
fd = open_device (disk, sector, O_WRONLY);
|
||||
if (fd < 0)
|
||||
return grub_errno;
|
||||
|
|
Loading…
Reference in a new issue