1
Description: Handle partition devices without corresponding disk devices
2
On Xen, it's possible to assign disk images in the host to things that are
3
named rather like partitions in the guest (e.g. /dev/sda1), but that don't
4
have an associated disk (e.g. /dev/sda); indeed, the latter device is
5
nonexistent. This confuses grub_util_biosdisk_get_grub_dev.
7
There's really no other situation in which I think it's terribly plausible
8
that you might have /dev/sda1 but not /dev/sda, so it seems to me that in
9
this case we can reasonably treat the apparent "partition" as a disk in its
11
Author: Colin Watson <cjwatson@ubuntu.com>
12
Bug-Ubuntu: https://bugs.launchpad.net/bugs/623609
14
Applied-Upstream: http://bazaar.launchpad.net/~vcs-imports/grub/grub2-bzr/revision/2832
15
Last-Update: 2010-09-21
17
Index: b/kern/emu/hostdisk.c
18
===================================================================
19
--- a/kern/emu/hostdisk.c
20
+++ b/kern/emu/hostdisk.c
21
@@ -1348,12 +1348,15 @@
22
#endif /* defined(__NetBSD__) */
25
-find_system_device (const char *os_dev, struct stat *st)
26
+find_system_device (const char *os_dev, struct stat *st, int convert)
31
- os_disk = convert_system_partition_to_system_disk (os_dev, st);
33
+ os_disk = convert_system_partition_to_system_disk (os_dev, st);
35
+ os_disk = xstrdup (os_dev);
43
- drive = find_system_device (os_dev, &st);
44
+ drive = find_system_device (os_dev, &st, 1);
47
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
48
@@ -1542,7 +1545,32 @@
54
+ /* We already know that the partition exists. Given that we already
55
+ checked the device map above, we can only get
56
+ GRUB_ERR_UNKNOWN_DEVICE at this point if the disk does not exist.
57
+ This can happen on Xen, where disk images in the host can be
58
+ assigned to devices that have partition-like names in the guest
59
+ but are really more like disks. */
60
+ if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
63
+ ("disk does not exist, so falling back to partition device %s",
66
+ drive = find_system_device (os_dev, &st, 0);
69
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE,
70
+ "no mapping exists for `%s'", os_dev);
74
+ return make_device_name (drive, -1, -1);
81
grub_partition_iterate (disk, find_partition);