diff options
author | Ian Campbell <ijc@hellion.org.uk> | 2008-02-21 16:03:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-21 19:19:13 -0500 |
commit | 597592d951cdca8e5edb29f7e8174f633a69685a (patch) | |
tree | 7bbdf03e4cdc94086489616c65759962e6fb28f1 /drivers/block | |
parent | 0f151e8b214c1df3f571020b849382933f2cdce7 (diff) |
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 <ijc@hellion.org.uk>
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | 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 8afce67c0aa5..9c6f3f99208d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
40 | #include <linux/hdreg.h> | ||
40 | #include <linux/module.h> | 41 | #include <linux/module.h> |
41 | 42 | ||
42 | #include <xen/xenbus.h> | 43 | #include <xen/xenbus.h> |
@@ -135,6 +136,22 @@ static void blkif_restart_queue_callback(void *arg) | |||
135 | schedule_work(&info->work); | 136 | schedule_work(&info->work); |
136 | } | 137 | } |
137 | 138 | ||
139 | int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) | ||
140 | { | ||
141 | /* We don't have real geometry info, but let's at least return | ||
142 | values consistent with the size of the device */ | ||
143 | sector_t nsect = get_capacity(bd->bd_disk); | ||
144 | sector_t cylinders = nsect; | ||
145 | |||
146 | hg->heads = 0xff; | ||
147 | hg->sectors = 0x3f; | ||
148 | sector_div(cylinders, hg->heads * hg->sectors); | ||
149 | hg->cylinders = cylinders; | ||
150 | if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect) | ||
151 | hg->cylinders = 0xffff; | ||
152 | return 0; | ||
153 | } | ||
154 | |||
138 | /* | 155 | /* |
139 | * blkif_queue_request | 156 | * blkif_queue_request |
140 | * | 157 | * |
@@ -937,6 +954,7 @@ static struct block_device_operations xlvbd_block_fops = | |||
937 | .owner = THIS_MODULE, | 954 | .owner = THIS_MODULE, |
938 | .open = blkif_open, | 955 | .open = blkif_open, |
939 | .release = blkif_release, | 956 | .release = blkif_release, |
957 | .getgeo = blkif_getgeo, | ||
940 | }; | 958 | }; |
941 | 959 | ||
942 | 960 | ||