1
Description: Adjust hostdisk id for hard disks
2
This allows grub-setup to use its standard workaround for broken BIOSes.
3
Author: Colin Watson <cjwatson@ubuntu.com>
4
Bug: http://savannah.gnu.org/bugs/?29464
5
Bug-Ubuntu: https://bugs.launchpad.net/bugs/555500
6
Forwarded: http://savannah.gnu.org/bugs/?29464
7
Last-Update: 2010-04-08
9
Index: b/kern/emu/hostdisk.c
10
===================================================================
11
--- a/kern/emu/hostdisk.c
12
+++ b/kern/emu/hostdisk.c
15
disk->has_partitions = 1;
17
+ if (strncmp (map[drive].drive, "hd", 2) == 0)
19
disk->data = data = xmalloc (sizeof (struct grub_util_biosdisk_data));
21
data->access_mode = 0;
24
part_start = grub_partition_get_start (disk->partition);
26
- strcpy (dev, map[disk->id].device);
27
+ strcpy (dev, map[disk->id & 0x7f].device);
28
if (disk->partition && sector >= part_start
29
- && strncmp (map[disk->id].device, "/dev/", 5) == 0)
30
+ && strncmp (map[disk->id & 0x7f].device, "/dev/", 5) == 0)
31
is_partition = linux_find_partition (dev, part_start);
33
if (data->dev && strcmp (data->dev, dev) == 0 &&
38
- if (data->dev && strcmp (data->dev, map[disk->id].device) == 0 &&
39
+ if (data->dev && strcmp (data->dev, map[disk->id & 0x7f].device) == 0 &&
40
data->access_mode == (flags & O_ACCMODE))
42
grub_dprintf ("hostdisk", "reusing open device `%s'\n", data->dev);
47
- fd = open (map[disk->id].device, flags);
48
+ fd = open (map[disk->id & 0x7f].device, flags);
51
- data->dev = xstrdup (map[disk->id].device);
52
+ data->dev = xstrdup (map[disk->id & 0x7f].device);
53
data->access_mode = (flags & O_ACCMODE);
57
#if defined(__APPLE__)
58
/* If we can't have exclusive access, try shared access */
60
- fd = open(map[disk->id].device, flags | O_SHLOCK);
61
+ fd = open(map[disk->id & 0x7f].device, flags | O_SHLOCK);
66
- grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' in open_device()", map[disk->id].device);
67
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' in open_device()", map[disk->id & 0x7f].device);
70
#endif /* ! __linux__ */
72
offset = (loff_t) sector << GRUB_DISK_SECTOR_BITS;
73
if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
75
- grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", map[disk->id].device);
76
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", map[disk->id & 0x7f].device);
82
if (lseek (fd, offset, SEEK_SET) != offset)
84
- grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", map[disk->id].device);
85
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", map[disk->id & 0x7f].device);
91
if (nread (fd, buf, GRUB_DISK_SECTOR_SIZE) != GRUB_DISK_SECTOR_SIZE)
93
- grub_error (GRUB_ERR_READ_ERROR, "cannot read `%s'", map[disk->id].device);
94
+ grub_error (GRUB_ERR_READ_ERROR, "cannot read `%s'", map[disk->id & 0x7f].device);
100
if (nread (fd, buf, size << GRUB_DISK_SECTOR_BITS)
101
!= (ssize_t) (size << GRUB_DISK_SECTOR_BITS))
102
- grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", map[disk->id].device);
103
+ grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", map[disk->id & 0x7f].device);
109
if (nwrite (fd, buf, size << GRUB_DISK_SECTOR_BITS)
110
!= (ssize_t) (size << GRUB_DISK_SECTOR_BITS))
111
- grub_error (GRUB_ERR_WRITE_ERROR, "cannot write to `%s'", map[disk->id].device);
112
+ grub_error (GRUB_ERR_WRITE_ERROR, "cannot write to `%s'", map[disk->id & 0x7f].device);
116
@@ -1634,5 +1636,5 @@
118
grub_util_biosdisk_get_osdev (grub_disk_t disk)
120
- return map[disk->id].device;
121
+ return map[disk->id & 0x7f].device;