From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH, resend] blkfront: ioctls/geometry, 2.6 Date: Fri, 02 Jun 2006 12:05:01 +0200 Message-ID: <4480296D.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartFCD9355D.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartFCD9355D.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Add backing support for HDIO_GETGEO ioctl to blkfront. Inspired by an earlier patch from Charles Coffing. Signed-Off-By: Jan Beulich --=__PartFCD9355D.0__= Content-Type: text/plain; name="xenlinux-blkfront-getgeo.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xenlinux-blkfront-getgeo.patch" Index: head-2006-05-11/drivers/xen/blkfront/blkfront.c =================================================================== --- head-2006-05-11.orig/drivers/xen/blkfront/blkfront.c 2006-05-12 09:39:21.000000000 +0200 +++ head-2006-05-11/drivers/xen/blkfront/blkfront.c 2006-05-15 09:59:52.000000000 +0200 @@ -452,10 +452,6 @@ int blkif_ioctl(struct inode *inode, str 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, str } +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: head-2006-05-11/drivers/xen/blkfront/block.h =================================================================== --- head-2006-05-11.orig/drivers/xen/blkfront/block.h 2006-05-12 09:39:21.000000000 +0200 +++ head-2006-05-11/drivers/xen/blkfront/block.h 2006-05-10 11:06:51.000000000 +0200 @@ -140,6 +140,7 @@ extern int blkif_open(struct inode *inod 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: head-2006-05-11/drivers/xen/blkfront/vbd.c =================================================================== --- head-2006-05-11.orig/drivers/xen/blkfront/vbd.c 2006-05-12 09:39:21.000000000 +0200 +++ head-2006-05-11/drivers/xen/blkfront/vbd.c 2006-05-10 11:07:16.000000000 +0200 @@ -91,6 +91,7 @@ static struct block_device_operations xl .open = blkif_open, .release = blkif_release, .ioctl = blkif_ioctl, + .getgeo = blkif_getgeo }; DEFINE_SPINLOCK(blkif_io_lock); --=__PartFCD9355D.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartFCD9355D.0__=--