1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
--- util/hostdisk.c 2010-01-25 17:04:22 +0000
+++ util/hostdisk.c 2010-01-31 11:52:27 +0000
@@ -336,7 +336,8 @@
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 @@
{
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 @@
{
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;
|