45
45
===================================================================
46
46
--- a/grub-core/kern/emu/hostdisk.c
47
47
+++ b/grub-core/kern/emu/hostdisk.c
48
@@ -1659,6 +1659,48 @@
48
@@ -1008,6 +1008,24 @@
53
+canonicalize_device_name (const char *path)
58
+ /* Leave /dev/mapper/ alone on Linux; such devices are the canonical form
59
+ despite sometimes being symlinks. */
60
+ if (strncmp (path, "/dev/mapper/", 12) == 0)
61
+ return xstrdup (path);
64
+ ret = canonicalize_file_name (path);
66
+ grub_util_error ("cannot get the real path of `%s'", path);
71
read_device_map (const char *dev_map)
73
@@ -1102,19 +1120,7 @@
78
- /* On Linux, the devfs uses symbolic links horribly, and that
79
- confuses the interface very much, so use realpath to expand
80
- symbolic links. Leave /dev/mapper/ alone, though. */
81
- if (strncmp (p, "/dev/mapper/", 12) != 0)
83
- map[drive].device = xmalloc (PATH_MAX);
84
- if (! realpath (p, map[drive].device))
85
- grub_util_error ("cannot get the real path of `%s'", p);
89
- map[drive].device = xstrdup (p);
90
+ map[drive].device = canonicalize_device_name (p);
96
os_disk = convert_system_partition_to_system_disk (os_dev, st);
98
- os_disk = xstrdup (os_dev);
99
+ os_disk = canonicalize_device_name (os_dev);
103
@@ -1659,6 +1665,51 @@
49
104
return find_system_device (os_dev, &st, 1, 0) != -1;
53
108
+store_grub_dev (const char *grub_disk, const char *os_disk)
111
+ char *canonical_os_disk;
113
+ canonical_os_disk = canonicalize_device_name (os_disk);
57
115
+ for (i = 0; i < ARRAY_SIZE (map); i++)
58
116
+ if (! map[i].device)
60
118
+ else if (strcmp (map[i].drive, grub_disk) == 0)
62
+ if (strcmp (map[i].device, os_disk) == 0)
120
+ if (strcmp (map[i].device, canonical_os_disk) == 0)
64
122
+ grub_util_error (_("drive `%s' already mapped to `%s'"),
65
123
+ map[i].drive, map[i].device);