Robert Millan wrote:
On Sun, Nov 18, 2007 at 07:40:15PM +0100, Christian Franke wrote:
No, it did not work because check_device() returned 1 ("exists") on
(*name == 0). This results in 8 bogus "(hd N)\t\n" lines and wrong N for
the real devices.
Yes, it would work now, because the patch also fixes this bug :-)
Ok, so in that case you don't need...
+#ifndef __CYGWIN__
...
+#ifndef __CYGWIN__
...
+#endif /* __CYGWIN__ */
...because you already fixed the problem in:
- /* If DEVICE is empty, just return 1. */
+ /* If DEVICE is empty, just return error. */
if (*device == 0)
- return 1;
-
+ return 0;
?
New version of the patch is attached.
Christian
2007-12-28 Christian Franke <[EMAIL PROTECTED]>
* util/grub-mkdevicemap.c (get_floppy_disk_name) [__CYGWIN__]:
Add Cygwin device names.
(get_ide_disk_name) [__CYGWIN__]: Likewise.
(get_scsi_disk_name) [__CYGWIN__]: Likewise.
(check_device): Add static.
Return error instead of success on empty name.
(make_device_map): Move label inside linux specific code to
prevent compiler warning.
--- grub2.orig/util/grub-mkdevicemap.c 2007-12-25 23:15:25.750000000 +0100
+++ grub2/util/grub-mkdevicemap.c 2007-12-28 16:14:25.437500000 +0100
@@ -166,6 +166,9 @@ get_floppy_disk_name (char *name, int un
#elif defined(__QNXNTO__)
/* QNX RTP */
sprintf (name, "/dev/fd%d", unit);
+#elif defined(__CYGWIN__)
+ /* Cygwin */
+ sprintf (name, "/dev/fd%d", unit);
#else
# warning "BIOS floppy drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@@ -207,6 +210,10 @@ get_ide_disk_name (char *name, int unit)
/* Actually, QNX RTP doesn't distinguish IDE from SCSI, so this could
contain SCSI disks. */
sprintf (name, "/dev/hd%d", unit);
+#elif defined(__CYGWIN__)
+ /* Cygwin emulates all disks as /dev/sdX. */
+ (void) unit;
+ *name = 0;
#else
# warning "BIOS IDE drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@@ -248,6 +255,9 @@ get_scsi_disk_name (char *name, int unit
/* QNX RTP doesn't distinguish SCSI from IDE, so it is better to
disable the detection of SCSI disks here. */
*name = 0;
+#elif defined(__CYGWIN__)
+ /* Cygwin emulates all disks as /dev/sdX. */
+ sprintf (name, "/dev/sd%c", unit + 'a');
#else
# warning "BIOS SCSI drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@@ -277,15 +287,15 @@ get_i2o_disk_name (char *name, char unit
/* Check if DEVICE can be read. If an error occurs, return zero,
otherwise return non-zero. */
-int
+static int
check_device (const char *device)
{
char buf[512];
FILE *fp;
- /* If DEVICE is empty, just return 1. */
+ /* If DEVICE is empty, just return error. */
if (*device == 0)
- return 1;
+ return 0;
fp = fopen (device, "r");
if (! fp)
@@ -513,9 +523,10 @@ make_device_map (const char *device_map,
}
}
}
-#endif /* __linux__ */
finish:
+#endif /* __linux__ */
+
if (fp != stdout)
fclose (fp);
}
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel