diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2008-01-23 11:56:50 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-02-04 07:50:09 -0500 |
commit | 135da0b037984c0284acdf40aaf4f7f31eb5cbd0 (patch) | |
tree | 733f368d62f5e1367550380d50c2e6d98e498660 /drivers/block/virtio_blk.c | |
parent | 6c0cd7c000dc0851035c5003bf9d47733d0b257b (diff) |
virtio_blk: provide getgeo
Rusty,
I currently try to make my guest boot from an virtio root device
without having an external kernel. Some of the tools that I tried
expect HDIO_GETGEO to work. The most interesting value is likely
the geo.start value to get the offset of a partition. This value
is filled by block/ioctl.c if fops->getgeo is set. This patch also
fills in some standard values for heads, sectors and cylinders.
Makes sense?
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r-- | drivers/block/virtio_blk.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 6143337527e7..d2fe679519e4 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -152,9 +152,20 @@ static int virtblk_ioctl(struct inode *inode, struct file *filp, | |||
152 | (void __user *)data); | 152 | (void __user *)data); |
153 | } | 153 | } |
154 | 154 | ||
155 | /* We provide getgeo only to please some old bootloader/partitioning tools */ | ||
156 | static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) | ||
157 | { | ||
158 | /* some standard values, similar to sd */ | ||
159 | geo->heads = 1 << 6; | ||
160 | geo->sectors = 1 << 5; | ||
161 | geo->cylinders = get_capacity(bd->bd_disk) >> 11; | ||
162 | return 0; | ||
163 | } | ||
164 | |||
155 | static struct block_device_operations virtblk_fops = { | 165 | static struct block_device_operations virtblk_fops = { |
156 | .ioctl = virtblk_ioctl, | 166 | .ioctl = virtblk_ioctl, |
157 | .owner = THIS_MODULE, | 167 | .owner = THIS_MODULE, |
168 | .getgeo = virtblk_getgeo, | ||
158 | }; | 169 | }; |
159 | 170 | ||
160 | static int virtblk_probe(struct virtio_device *vdev) | 171 | static int virtblk_probe(struct virtio_device *vdev) |