Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=597592d951cdca8e5edb29f7e8174f633a69685a
Commit:     597592d951cdca8e5edb29f7e8174f633a69685a
Parent:     0f151e8b214c1df3f571020b849382933f2cdce7
Author:     Ian Campbell <[EMAIL PROTECTED]>
AuthorDate: Thu Feb 21 13:03:45 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Feb 21 16:19:13 2008 -0800

    xen: Implement getgeo for Xen virtual block device.
    
    The below implements the getgeo hook for Xen block devices. Extracted
    from the xen-unstable tree where it has been used for ages.
    
    It is useful to have because it allows things like grub2 (used by the
    Debian installer images) to work in a guest domain without having to
    sprinkle Xen specific hacks around the place.
    
    Signed-off-by: Ian Campbell <[EMAIL PROTECTED]>
    Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 drivers/block/xen-blkfront.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 8afce67..9c6f3f9 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -37,6 +37,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/blkdev.h>
+#include <linux/hdreg.h>
 #include <linux/module.h>
 
 #include <xen/xenbus.h>
@@ -135,6 +136,22 @@ static void blkif_restart_queue_callback(void *arg)
        schedule_work(&info->work);
 }
 
+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
  *
@@ -937,6 +954,7 @@ static struct block_device_operations xlvbd_block_fops =
        .owner = THIS_MODULE,
        .open = blkif_open,
        .release = blkif_release,
+       .getgeo = blkif_getgeo,
 };
 
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to