WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Blkfront support for get geometry ioctl

To: xen-devel@xxxxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Blkfront support for get geometry ioctl
From: Stephen Childs <Stephen.Childs@xxxxxxxxx>
Date: Wed, 01 Sep 2004 11:54:24 +0100
Delivery-date: Wed, 01 Sep 2004 11:58:10 +0100
Envelope-to: steven.hand@xxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803
Hi,

Continuing my battle with LCFGng installation onto Xen, I was puzzled by the fact that whatever size drive I exported to Xen, the partitioning program always seemed to think the disk size was approx 2.1 GB. After some probing, I realised that the program LCFG uses to determine disk size (based on RedHat's libfdisk I think) does so by performing an ioctl to get the geometry of the disk. The code in blkfront "implements" the HDIO_GETGEO ioctl by returning garbage results for cyls, heads, and sectors/track. (the figures in question: 63*255*262 -- equals approx 2.1 GB!).

Do you think it would be possible to return geometry values that are at least consistent with the size of the device? Something like this (still has hard-coded heads and sectors, but calculates cyls based on size of disk):

--- xeno-unstable-pristine/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Sep 1 10:45:33 2004 +++ xeno-unstable.bk/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Sep 1 10:46:27 2004
@@ -510,6 +510,8 @@
     struct gendisk *gd;
     struct hd_struct *part;
     int i;
+    unsigned short cylinders;
+    byte heads, sectors;

     /* NB. No need to check permissions. That is done for us. */

@@ -554,23 +556,39 @@
         break;

     case HDIO_GETGEO:
-        /* note: these values are complete garbage */
         DPRINTK_IOCTL("   HDIO_GETGEO: %x\n", HDIO_GETGEO);
         if (!argument) return -EINVAL;
+
+        /* We don't have real geometry info, but let's at least return
+          values consistent with the size of the device */
+
+        heads = 0xff;
+        sectors = 0x3f;
+        cylinders = part->nr_sects / (heads * sectors);
+
         if (put_user(0x00,  (unsigned long *) &geo->start)) return -EFAULT;
-        if (put_user(0xff,  (byte *)&geo->heads)) return -EFAULT;
-        if (put_user(0x3f,  (byte *)&geo->sectors)) return -EFAULT;
-        if (put_user(0x106, (unsigned short *)&geo->cylinders)) return -EFAULT;
+        if (put_user(heads,  (byte *)&geo->heads)) return -EFAULT;
+        if (put_user(sectors,  (byte *)&geo->sectors)) return -EFAULT;
+ if (put_user(cylinders, (unsigned short *)&geo->cylinders)) return -EFAULT;
+
         return 0;

     case HDIO_GETGEO_BIG:
-        /* note: these values are complete garbage */
         DPRINTK_IOCTL("   HDIO_GETGEO_BIG: %x\n", HDIO_GETGEO_BIG);
         if (!argument) return -EINVAL;
+
+        /* We don't have real geometry info, but let's at least return
+          values consistent with the size of the device */
+
+        heads = 0xff;
+        sectors = 0x3f;
+        cylinders = part->nr_sects / (heads * sectors);
+
         if (put_user(0x00,  (unsigned long *) &geo->start))  return -EFAULT;
-        if (put_user(0xff,  (byte *)&geo->heads))   return -EFAULT;
-        if (put_user(0x3f,  (byte *)&geo->sectors)) return -EFAULT;
-        if (put_user(0x106, (unsigned int *) &geo->cylinders)) return -EFAULT;
+        if (put_user(heads,  (byte *)&geo->heads))   return -EFAULT;
+        if (put_user(sectors,  (byte *)&geo->sectors)) return -EFAULT;
+ if (put_user(cylinders, (unsigned int *) &geo->cylinders)) return -EFAULT;
+
         return 0;

     case CDROMMULTISESSION:

--
Dr. Stephen Childs,
Research Fellow, EGEE Project,    phone:                    +353-1-6081720
Computer Architecture Group,      email:        Stephen.Childs @ cs.tcd.ie
Trinity College Dublin, Ireland   web: http://www.cs.tcd.ie/Stephen.Childs


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel