From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pascal Bouchareine Subject: [PATCH] blkfront: ioctls/geometry, 2.6 Date: Mon, 15 May 2006 20:15:25 +0200 Message-ID: <20060515181525.GA2110@bar.gandi.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" Return-path: Content-Disposition: inline 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 --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Adds HDIO_GETGEO, BLKGETSIZE, BLKGETSIZE64 support to blkfront. An attempt to merge in the following sent previously by Ian Pratt : http://lists.xensource.com/archives/html/xen-devel/2005-01/msg00659.html Taking into account the block_device_operations for get_geom. Regards, Pascal -- \o/ Pascal Bouchareine - Gandi g 0170393757 15, place de la Nation - 75011 Paris --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="blkfront_ioctl_getgeo-2.6.patch" Signed-off-by: Pascal Bouchareine diff -ru xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c xen-unstable.hg.new/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c --- xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Sun Apr 30 13:36:52 2006 +++ xen-unstable.hg.new/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Mon May 15 20:01:07 2006 @@ -424,7 +424,6 @@ return 0; } - int blkif_release(struct inode *inode, struct file *filep) { struct blkfront_info *info = inode->i_bdev->bd_disk->private_data; @@ -442,19 +441,46 @@ return 0; } +int blkif_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + struct gendisk *gd; + struct hd_struct *part; + int dpart; + + DPRINTK_IOCTL("blkif ioctl(HDIO_GETGEO)\n"); + gd = bdev->bd_disk; + + geo->start = 0x00; + geo->heads = 0xff; + geo->sectors = 0x3f; + geo->cylinders = (gd->capacity >> 14) + (geo->heads + geo->sectors + 1); + + return 0; +} int blkif_ioctl(struct inode *inode, struct file *filep, unsigned command, unsigned long argument) { - int i; + dev_t dev = inode->i_rdev; + struct gendisk *gd; + struct hd_struct *part; + int i, num, dpart; DPRINTK_IOCTL("command: 0x%x, argument: 0x%lx, dev: 0x%04x\n", command, (long)argument, inode->i_rdev); + gd = get_gendisk(dev, &dpart); + part = gd->part[MINOR(dev)]; + switch (command) { - case HDIO_GETGEO: - /* return ENOSYS to use defaults */ - return -ENOSYS; + case BLKGETSIZE: + DPRINTK_IOCTL(" BLKGETSIZE: %x %lx\n", BLKGETSIZE, part->nr_sects); + return put_user(part->nr_sects, (unsigned long *) argument); + + case BLKGETSIZE64: + DPRINTK_IOCTL(" BLKGETSIZE64: %x %lx\n", BLKGETSIZE64, + (u64)part->nr_sects * 512); + return put_user((u64)part->nr_sects * 512, (u64 *) argument); case CDROMMULTISESSION: DPRINTK("FIXME: support multisession CDs later\n"); diff -ru xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h xen-unstable.hg.new/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h --- xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Sun Apr 30 13:36:52 2006 +++ xen-unstable.hg.new/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Mon May 15 15:57:58 2006 @@ -138,6 +138,7 @@ extern int blkif_open(struct inode *inode, struct file *filep); extern int blkif_release(struct inode *inode, struct file *filep); +extern int blkif_getgeo(struct block_device *bdev, struct hd_geometry *geo); extern int blkif_ioctl(struct inode *inode, struct file *filep, unsigned command, unsigned long argument); extern int blkif_check(dev_t dev); diff -ru xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c xen-unstable.hg.new/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c --- xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Sun Apr 30 13:36:52 2006 +++ xen-unstable.hg.new/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Mon May 15 15:57:58 2006 @@ -91,6 +91,7 @@ .open = blkif_open, .release = blkif_release, .ioctl = blkif_ioctl, + .getgeo = blkif_getgeo, }; spinlock_t blkif_io_lock = SPIN_LOCK_UNLOCKED; --k1lZvvs/B4yU6o8G 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 --k1lZvvs/B4yU6o8G--