Linux's Documentation/devices.txt file says that up to 256 SCSI disks
are supported. GRUB currently only supports the first 16. Wikimedia
filed an Ubuntu bug report about this
(https://bugs.launchpad.net/bugs/335174), so here's a patch to extend
this. (I really haven't been able to test this much at all beyond
compile-testing as I don't have a suitable system myself ...)
I suppose it might be nice to macroify the stuff in
grub_util_getdiskname, but TBH I'm not sure it would shorten it all that
much or make it much more readable, so I didn't bother.
Thanks,
--
Colin Watson [[email protected]]
Index: util/raid.c
===================================================================
--- util/raid.c (revision 2016)
+++ util/raid.c (working copy)
@@ -32,6 +32,16 @@
#include <linux/raid/md_p.h>
#include <linux/raid/md_u.h>
+static void
+grub_util_getdiskname_scsi (char *name, int scsi_major, int scsi_minor)
+{
+ int unit = scsi_major * 16 + scsi_minor;
+ if (unit < 26)
+ sprintf (name, "/dev/sd%c", 'a' + unit);
+ else
+ sprintf (name, "/dev/sd%c%c", 'a' + unit / 26 - 1, 'a' + unit % 26);
+}
+
static char *
grub_util_getdiskname (int major, int minor)
{
@@ -48,7 +58,37 @@ grub_util_getdiskname (int major, int minor)
else if (major == IDE3_MAJOR)
sprintf (name, "/dev/hd%c", 'g' + minor / 64);
else if (major == SCSI_DISK0_MAJOR)
- sprintf (name, "/dev/sd%c", 'a' + minor / 16);
+ grub_util_getdiskname_scsi (name, 0, minor / 16);
+ else if (major == SCSI_DISK1_MAJOR)
+ grub_util_getdiskname_scsi (name, 1, minor / 16);
+ else if (major == SCSI_DISK2_MAJOR)
+ grub_util_getdiskname_scsi (name, 2, minor / 16);
+ else if (major == SCSI_DISK3_MAJOR)
+ grub_util_getdiskname_scsi (name, 3, minor / 16);
+ else if (major == SCSI_DISK4_MAJOR)
+ grub_util_getdiskname_scsi (name, 4, minor / 16);
+ else if (major == SCSI_DISK5_MAJOR)
+ grub_util_getdiskname_scsi (name, 5, minor / 16);
+ else if (major == SCSI_DISK6_MAJOR)
+ grub_util_getdiskname_scsi (name, 6, minor / 16);
+ else if (major == SCSI_DISK7_MAJOR)
+ grub_util_getdiskname_scsi (name, 7, minor / 16);
+ else if (major == SCSI_DISK8_MAJOR)
+ grub_util_getdiskname_scsi (name, 8, minor / 16);
+ else if (major == SCSI_DISK9_MAJOR)
+ grub_util_getdiskname_scsi (name, 9, minor / 16);
+ else if (major == SCSI_DISK10_MAJOR)
+ grub_util_getdiskname_scsi (name, 10, minor / 16);
+ else if (major == SCSI_DISK11_MAJOR)
+ grub_util_getdiskname_scsi (name, 11, minor / 16);
+ else if (major == SCSI_DISK12_MAJOR)
+ grub_util_getdiskname_scsi (name, 12, minor / 16);
+ else if (major == SCSI_DISK13_MAJOR)
+ grub_util_getdiskname_scsi (name, 13, minor / 16);
+ else if (major == SCSI_DISK14_MAJOR)
+ grub_util_getdiskname_scsi (name, 14, minor / 16);
+ else if (major == SCSI_DISK15_MAJOR)
+ grub_util_getdiskname_scsi (name, 15, minor / 16);
else
grub_util_error ("Unknown device number: %d, %d", major, minor);
Index: util/grub-mkdevicemap.c
===================================================================
--- util/grub-mkdevicemap.c (revision 2016)
+++ util/grub-mkdevicemap.c (working copy)
@@ -231,7 +231,10 @@ get_scsi_disk_name (char *name, int unit)
{
#if defined(__linux__)
/* GNU/Linux */
- sprintf (name, "/dev/sd%c", unit + 'a');
+ if (unit < 26)
+ sprintf (name, "/dev/sd%c", unit + 'a');
+ else
+ sprintf (name, "/dev/sd%c%c", unit / 26 - 1 + 'a', unit % 26 + 'a');
#elif defined(__GNU__)
/* GNU/Hurd */
sprintf (name, "/dev/sd%d", unit);
@@ -516,7 +519,11 @@ make_device_map (const char *device_map, int flopp
#endif /* __linux__ */
/* The rest is SCSI disks. */
+#ifdef __linux__
+ for (i = 0; i < 256; i++)
+#else
for (i = 0; i < 16; i++)
+#endif /* __linux__ */
{
char name[16];
Index: util/hostdisk.c
===================================================================
--- util/hostdisk.c (revision 2016)
+++ util/hostdisk.c (working copy)
@@ -709,8 +709,12 @@ convert_system_partition_to_system_disk (const cha
|| strncmp ("sd", p, 2) == 0)
&& p[2] >= 'a' && p[2] <= 'z')
{
- /* /dev/[hsv]d[a-z][0-9]* */
- p[3] = '\0';
+ if (p[3] >= 'a' && p[3] <= 'z')
+ /* /dev/[hsv]d[a-z][a-z][0-9]* */
+ p[4] = '\0';
+ else
+ /* /dev/[hsv]d[a-z][0-9]* */
+ p[3] = '\0';
return path;
}
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel