ia64/xen-unstable

changeset 10296:bcc2c9ea60d8

Add backing support for HDIO_GETGEO ioctl to blkfront.
Inspired by an earlier patch from Charles Coffing.
Signed-Off-By: Jan Beulich <jbeulich@novell.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 02 12:13:34 2006 +0100 (2006-06-02)
parents b198bbfeec10
children 8425df2203c9
files 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
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Jun 02 11:46:24 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Jun 02 12:13:34 2006 +0100
     1.3 @@ -452,10 +452,6 @@ int blkif_ioctl(struct inode *inode, str
     1.4  		      command, (long)argument, inode->i_rdev);
     1.5  
     1.6  	switch (command) {
     1.7 -	case HDIO_GETGEO:
     1.8 -		/* return ENOSYS to use defaults */
     1.9 -		return -ENOSYS;
    1.10 -
    1.11  	case CDROMMULTISESSION:
    1.12  		DPRINTK("FIXME: support multisession CDs later\n");
    1.13  		for (i = 0; i < sizeof(struct cdrom_multisession); i++)
    1.14 @@ -473,6 +469,23 @@ int blkif_ioctl(struct inode *inode, str
    1.15  }
    1.16  
    1.17  
    1.18 +int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg)
    1.19 +{
    1.20 +	/* We don't have real geometry info, but let's at least return
    1.21 +	   values consistent with the size of the device */
    1.22 +	sector_t nsect = get_capacity(bd->bd_disk);
    1.23 +	sector_t cylinders = nsect;
    1.24 +
    1.25 +	hg->heads = 0xff;
    1.26 +	hg->sectors = 0x3f;
    1.27 +	sector_div(cylinders, hg->heads * hg->sectors);
    1.28 +	hg->cylinders = cylinders;
    1.29 +	if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect)
    1.30 +		hg->cylinders = 0xffff;
    1.31 +	return 0;
    1.32 +}
    1.33 +
    1.34 +
    1.35  /*
    1.36   * blkif_queue_request
    1.37   *
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Fri Jun 02 11:46:24 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Fri Jun 02 12:13:34 2006 +0100
     2.3 @@ -140,6 +140,7 @@ extern int blkif_open(struct inode *inod
     2.4  extern int blkif_release(struct inode *inode, struct file *filep);
     2.5  extern int blkif_ioctl(struct inode *inode, struct file *filep,
     2.6                         unsigned command, unsigned long argument);
     2.7 +extern int blkif_getgeo(struct block_device *, struct hd_geometry *);
     2.8  extern int blkif_check(dev_t dev);
     2.9  extern int blkif_revalidate(dev_t dev);
    2.10  extern void do_blkif_request (request_queue_t *rq);
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Jun 02 11:46:24 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Jun 02 12:13:34 2006 +0100
     3.3 @@ -91,6 +91,7 @@ static struct block_device_operations xl
     3.4  	.open = blkif_open,
     3.5  	.release = blkif_release,
     3.6  	.ioctl  = blkif_ioctl,
     3.7 +	.getgeo = blkif_getgeo
     3.8  };
     3.9  
    3.10  DEFINE_SPINLOCK(blkif_io_lock);