* [PATCH] mkdevicemap for Cygwin
@ 2007-11-13 20:42 Christian Franke
2007-11-18 6:24 ` Robert Millan
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Christian Franke @ 2007-11-13 20:42 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
Some changes for grub-mkdevicemap on Cygwin.
Christian
2007-11-13 Christian Franke <franke@computer.org>
* util/grub-mkdevicemap.c (get_floppy_disk_name): Add Cygwin
device names.
(get_ide_disk_name): Disable on __CYGWIN__.
(get_scsi_disk_name): Add Cygwin device names.
(check_device): Add static.
Return error instead of success on empty string.
(make_device_map): Disable IDE loop on __CYGWIN__.
Move label inside linux specific code to prevent compiler warning.
[-- Attachment #2: grub2-mkdevicemap-Cygwin.patch --]
[-- Type: text/x-patch, Size: 2243 bytes --]
--- grub2.orig/util/grub-mkdevicemap.c 2007-08-28 12:18:10.000000000 +0200
+++ grub2/util/grub-mkdevicemap.c 2007-11-13 21:27:18.265625000 +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. */
@@ -173,6 +176,7 @@ get_floppy_disk_name (char *name, int un
#endif
}
+#ifndef __CYGWIN__
static void
get_ide_disk_name (char *name, int unit)
{
@@ -213,6 +217,7 @@ get_ide_disk_name (char *name, int unit)
*name = 0;
#endif
}
+#endif /* __CYGWIN__ */
static void
get_scsi_disk_name (char *name, int unit)
@@ -248,6 +253,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,16 +285,16 @@ 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)
{
@@ -415,7 +423,8 @@ make_device_map (const char *device_map,
goto finish;
}
#endif /* __linux__ */
-
+
+#ifndef __CYGWIN__
/* IDE disks. */
for (i = 0; i < 8; i++)
{
@@ -431,6 +440,7 @@ make_device_map (const char *device_map,
num_hd++;
}
}
+#endif /* __CYGWIN__ */
#ifdef __linux__
/* ATARAID disks. */
@@ -513,9 +523,10 @@ make_device_map (const char *device_map,
}
}
}
-#endif /* __linux__ */
finish:
+#endif /* __linux__ */
+
if (fp != stdout)
fclose (fp);
}
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] mkdevicemap for Cygwin
2007-11-13 20:42 [PATCH] mkdevicemap for Cygwin Christian Franke
@ 2007-11-18 6:24 ` Robert Millan
2007-11-18 18:40 ` Christian Franke
2007-11-18 11:30 ` Marco Gerards
2007-12-06 12:15 ` Robert Millan
2 siblings, 1 reply; 14+ messages in thread
From: Robert Millan @ 2007-11-18 6:24 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Nov 13, 2007 at 09:42:26PM +0100, Christian Franke wrote:
> +#elif defined(__CYGWIN__)
> + /* Cygwin */
> + sprintf (name, "/dev/fd%d", unit);
Cygwin has /dev now? :-)
> +#ifndef __CYGWIN__
> static void
> get_ide_disk_name (char *name, int unit)
> {
> @@ -213,6 +217,7 @@ get_ide_disk_name (char *name, int unit)
> *name = 0;
> #endif
> }
> +#endif /* __CYGWIN__ */
> [...]
> +#ifndef __CYGWIN__
> /* IDE disks. */
> for (i = 0; i < 8; i++)
> {
> @@ -431,6 +440,7 @@ make_device_map (const char *device_map,
> num_hd++;
> }
> }
> +#endif /* __CYGWIN__ */
Is the generic case (`*name = 0', then print that) good enough?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] mkdevicemap for Cygwin
2007-11-18 6:24 ` Robert Millan
@ 2007-11-18 18:40 ` Christian Franke
0 siblings, 0 replies; 14+ messages in thread
From: Christian Franke @ 2007-11-18 18:40 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan wrote:
> On Tue, Nov 13, 2007 at 09:42:26PM +0100, Christian Franke wrote:
>
>> +#elif defined(__CYGWIN__)
>> + /* Cygwin */
>> + sprintf (name, "/dev/fd%d", unit);
>>
>
> Cygwin has /dev now? :-)
>
>
At least since 2003.
>> +#ifndef __CYGWIN__
>> static void
>> get_ide_disk_name (char *name, int unit)
>> {
>> @@ -213,6 +217,7 @@ get_ide_disk_name (char *name, int unit)
>> *name = 0;
>> #endif
>> }
>> +#endif /* __CYGWIN__ */
>>
>
>
>> [...]
>>
>
>
>> +#ifndef __CYGWIN__
>> /* IDE disks. */
>> for (i = 0; i < 8; i++)
>> {
>> @@ -431,6 +440,7 @@ make_device_map (const char *device_map,
>> num_hd++;
>> }
>> }
>> +#endif /* __CYGWIN__ */
>>
>
> Is the generic case (`*name = 0', then print that) good enough?
>
>
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 :-)
Christian
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] mkdevicemap for Cygwin
2007-11-13 20:42 [PATCH] mkdevicemap for Cygwin Christian Franke
2007-11-18 6:24 ` Robert Millan
@ 2007-11-18 11:30 ` Marco Gerards
2007-11-18 18:46 ` Christian Franke
2007-12-06 12:15 ` Robert Millan
2 siblings, 1 reply; 14+ messages in thread
From: Marco Gerards @ 2007-11-18 11:30 UTC (permalink / raw)
To: The development of GRUB 2
Christian Franke <Christian.Franke@t-online.de> writes:
> Some changes for grub-mkdevicemap on Cygwin.
>
> Christian
>
> 2007-11-13 Christian Franke <franke@computer.org>
>
> * util/grub-mkdevicemap.c (get_floppy_disk_name): Add Cygwin
> device names.
> (get_ide_disk_name): Disable on __CYGWIN__.
[__CYGWIN__] (get_ide_disk_name): Disable.
> (get_scsi_disk_name): Add Cygwin device names.
> (check_device): Add static.
> Return error instead of success on empty string.
Can you explain this? Does this break something on GNU/Linux?
> (make_device_map): Disable IDE loop on __CYGWIN__.
[__CYGWIN__] (make_device_map): Disable IDE loop.
> Move label inside linux specific code to prevent compiler warning.
(make_device_map): Move label inside linux specific code to
prevent compiler warning.
Otherwise fine, so this can be committed if there aren't any other
problems with this patch.
--
Marco
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] mkdevicemap for Cygwin
2007-11-18 11:30 ` Marco Gerards
@ 2007-11-18 18:46 ` Christian Franke
0 siblings, 0 replies; 14+ messages in thread
From: Christian Franke @ 2007-11-18 18:46 UTC (permalink / raw)
To: The development of GRUB 2
Marco Gerards wrote:
> Christian Franke <Christian.Franke@t-online.de> writes:
>
>
>> Some changes for grub-mkdevicemap on Cygwin.
>>
>> Christian
>>
>> 2007-11-13 Christian Franke <franke@computer.org>
>>
>> * util/grub-mkdevicemap.c (get_floppy_disk_name): Add Cygwin
>> device names.
>> (get_ide_disk_name): Disable on __CYGWIN__.
>>
>
> [__CYGWIN__] (get_ide_disk_name): Disable.
>
>
>> (get_scsi_disk_name): Add Cygwin device names.
>> (check_device): Add static.
>> Return error instead of success on empty string.
>>
>
> Can you explain this? Does this break something on GNU/Linux?
>
>
See last mail. Should not break GNU/Linux, because (*name = 0) is not
used then.
>> (make_device_map): Disable IDE loop on __CYGWIN__.
>>
>
> [__CYGWIN__] (make_device_map): Disable IDE loop.
>
>
>> Move label inside linux specific code to prevent compiler warning.
>>
>
> (make_device_map): Move label inside linux specific code to
> prevent compiler warning.
>
> Otherwise fine, so this can be committed if there aren't any other
> problems with this patch.
>
Thanks, new changelog below.
Christian
2007-11-18 Christian Franke <franke@computer.org>
* util/grub-mkdevicemap.c (get_floppy_disk_name): Add Cygwin
device names.
[__CYGWIN__] (get_ide_disk_name): Disable.
(get_scsi_disk_name): Add Cygwin device names.
(check_device): Add static.
Return error instead of success on empty string.
[__CYGWIN__] (make_device_map): Disable IDE loop.
(make_device_map): Move label inside linux specific code to
prevent compiler warning.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] mkdevicemap for Cygwin
2007-11-13 20:42 [PATCH] mkdevicemap for Cygwin Christian Franke
2007-11-18 6:24 ` Robert Millan
2007-11-18 11:30 ` Marco Gerards
@ 2007-12-06 12:15 ` Robert Millan
2007-12-06 13:08 ` Christian Franke
2007-12-28 15:43 ` Christian Franke
2 siblings, 2 replies; 14+ messages in thread
From: Robert Millan @ 2007-12-06 12:15 UTC (permalink / raw)
To: The development of GRUB 2
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__
> static void
> get_ide_disk_name (char *name, int unit)
> {
> @@ -213,6 +217,7 @@ get_ide_disk_name (char *name, int unit)
> *name = 0;
> #endif
> }
> +#endif /* __CYGWIN__ */
>
> [...]
> +#ifndef __CYGWIN__
> /* IDE disks. */
> for (i = 0; i < 8; i++)
> {
> @@ -431,6 +440,7 @@ make_device_map (const char *device_map,
> num_hd++;
> }
> }
> +#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;
?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] mkdevicemap for Cygwin
2007-12-06 12:15 ` Robert Millan
@ 2007-12-06 13:08 ` Christian Franke
2007-12-28 15:43 ` Christian Franke
1 sibling, 0 replies; 14+ messages in thread
From: Christian Franke @ 2007-12-06 13:08 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan wrote:
> > ...
> > Yes, it would work now, because the patch also fixes this bug :-)
>
> Ok, so in that case you don't need...
>
> > +#ifndef __CYGWIN__
> > static void
> > get_ide_disk_name (char *name, int unit)
> > {
> > @@ -213,6 +217,7 @@ get_ide_disk_name (char *name, int unit)
> > *name = 0;
> > #endif
> > }
> > +#endif /* __CYGWIN__ */
> >
> > [...]
> > +#ifndef __CYGWIN__
> > /* IDE disks. */
> > for (i = 0; i < 8; i++)
> > {
> > @@ -431,6 +440,7 @@ make_device_map (const char *device_map,
> > num_hd++;
> > }
> > }
> > +#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;
>
> ?
Yes. I you want this alternative instead, and there are no other issues
with this patch, I'm happy to post a new version.
Christian
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] mkdevicemap for Cygwin
2007-12-06 12:15 ` Robert Millan
2007-12-06 13:08 ` Christian Franke
@ 2007-12-28 15:43 ` Christian Franke
2008-01-23 11:40 ` Marco Gerards
1 sibling, 1 reply; 14+ messages in thread
From: Christian Franke @ 2007-12-28 15:43 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]
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 <franke@computer.org>
* 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.
[-- Attachment #2: grub2-mkdevicemap-Cygwin-2.patch --]
[-- Type: text/x-patch, Size: 1982 bytes --]
--- 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);
}
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-05-05 21:27 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-13 20:42 [PATCH] mkdevicemap for Cygwin Christian Franke
2007-11-18 6:24 ` Robert Millan
2007-11-18 18:40 ` Christian Franke
2007-11-18 11:30 ` Marco Gerards
2007-11-18 18:46 ` Christian Franke
2007-12-06 12:15 ` Robert Millan
2007-12-06 13:08 ` Christian Franke
2007-12-28 15:43 ` Christian Franke
2008-01-23 11:40 ` Marco Gerards
2008-01-23 11:45 ` Robert Millan
2008-01-23 12:22 ` Marco Gerards
2008-01-23 20:40 ` Christian Franke
2008-04-24 20:06 ` Marco Gerards
2008-05-05 21:26 ` Christian Franke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.