]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Add backing support for HDIO_GETGEO ioctl to blkfront.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 2 Jun 2006 11:15:49 +0000 (12:15 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 2 Jun 2006 11:15:49 +0000 (12:15 +0100)
Inspired by an earlier patch from Charles Coffing.
Signed-Off-By: Jan Beulich <jbeulich@novell.com>
xen-unstable changeset:   10258:bcc2c9ea60d83e26940985d0e840d101e260ee57
xen-unstable date:        Fri Jun  2 12:13:34 2006 +0100

linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c

index 57b5c27592b231aea9306dc1853ca38f9bb6a85e..8a5ec33b10983f761e5277e5403598995c9582e9 100644 (file)
@@ -452,10 +452,6 @@ int blkif_ioctl(struct inode *inode, struct file *filep,
                      command, (long)argument, inode->i_rdev);
 
        switch (command) {
-       case HDIO_GETGEO:
-               /* return ENOSYS to use defaults */
-               return -ENOSYS;
-
        case CDROMMULTISESSION:
                DPRINTK("FIXME: support multisession CDs later\n");
                for (i = 0; i < sizeof(struct cdrom_multisession); i++)
@@ -473,6 +469,23 @@ int blkif_ioctl(struct inode *inode, struct file *filep,
 }
 
 
+int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg)
+{
+       /* We don't have real geometry info, but let's at least return
+          values consistent with the size of the device */
+       sector_t nsect = get_capacity(bd->bd_disk);
+       sector_t cylinders = nsect;
+
+       hg->heads = 0xff;
+       hg->sectors = 0x3f;
+       sector_div(cylinders, hg->heads * hg->sectors);
+       hg->cylinders = cylinders;
+       if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect)
+               hg->cylinders = 0xffff;
+       return 0;
+}
+
+
 /*
  * blkif_queue_request
  *
index 7ffd68b3b7c9d022bf5ffe69f1abf940c5321ad9..91f152dacf70e31eb93bf1bfddd075679042789e 100644 (file)
@@ -140,6 +140,7 @@ extern int blkif_open(struct inode *inode, struct file *filep);
 extern int blkif_release(struct inode *inode, struct file *filep);
 extern int blkif_ioctl(struct inode *inode, struct file *filep,
                        unsigned command, unsigned long argument);
+extern int blkif_getgeo(struct block_device *, struct hd_geometry *);
 extern int blkif_check(dev_t dev);
 extern int blkif_revalidate(dev_t dev);
 extern void do_blkif_request (request_queue_t *rq);
index 81d9c7fb8c84dc45e96b6a2ec7ee5c09fc54b192..7b68f45ffc081f9a5315591895cdd420a4ba1676 100644 (file)
@@ -91,6 +91,7 @@ static struct block_device_operations xlvbd_block_fops =
        .open = blkif_open,
        .release = blkif_release,
        .ioctl  = blkif_ioctl,
+       .getgeo = blkif_getgeo
 };
 
 spinlock_t blkif_io_lock = SPIN_LOCK_UNLOCKED;