Marius Vollmer <[EMAIL PROTECTED]> writes:

> Hi,
> 
> I have trouble accessing the CD-ROM drive from GNU/Hurd.  I have the
> Hurd running in a VMware virtual machine, with a virtual drive on hd0,
> and a virtual ATAPI CD-ROM on hd1.
> 
> After login in as root, I do
> 
>     # cd /dev
>     # MAKEDEV hd1
>     # showtrans hd1
>     /hurd/storeio hd1
>     # cat hd1
>     cat: hd1: Invalid argument

After some investigation, I came up with the following patch to GNU
Mach that solves this problem for me:

Index: block.c
===================================================================
RCS file: /cvs/gnumach/linux/dev/glue/block.c,v
retrieving revision 1.3
diff -u -r1.3 block.c
--- block.c     1999/06/27 23:51:47     1.3
+++ block.c     2000/08/15 00:02:54
@@ -1597,7 +1597,17 @@
     case DEV_GET_SIZE:
       if (disk_major (MAJOR (bd->dev)))
        {
+         unsigned real_minor;
+
          assert (bd->ds->gd);
+         
+         real_minor = MINOR (bd->dev) >> bd->ds->gd->minor_shift;
+         if ((real_minor << bd->ds->gd->minor_shift) != MINOR (bd->dev))
+           real_minor = MINOR (bd->dev);
+
+         printf ("dev %x, minor_shift %d, minor %d, real_minor %d\n",
+                 bd->dev, bd->ds->gd->minor_shift,
+                 MINOR(bd->dev), real_minor);
 
          if (bd->part >= 0)
            {
@@ -1611,7 +1621,7 @@
            }
          else
            (status[DEV_GET_SIZE_DEVICE_SIZE]
-            = bd->ds->gd->part[MINOR (bd->dev)].nr_sects << 9);
+            = bd->ds->gd->part[real_minor].nr_sects << 9);
        }
       else
        {

I have no idea what I really did, all I noticed was that
device_get_status was returning a bogus size for hd1 because it
accessed bd->ds->gd->part[64], and that I needed to shift the minor
number to get to the right index, which is 1.  However, shifting
always made the system fail in other ways, when calling
device_get_status for a dev number of 0x301, which apparantly refers
to my root partition hd0s1.

So I'm confused now.  I hope someone can devise a real fix.

Reply via email to