Skip to content

Commit 440a01a

Browse files
Christian LimpachJens Axboe
authored andcommitted
xen/blkfront: Add the CDROM_GET_CAPABILITY ioctl to blkfront.
Return 0 instead of -EINVAL if the blkfront device is a cdrom, i.e. had the VDISK_CDROM attribute. This allows udev's cdrom_id to correctly detect the device as a cdrom device. [ Add blkif_ioctl, and CDROMMULTISESSION ] [ linux-2.6.18-xen changeset d2bd9af846b5 ] Signed-off-by: Christian Limpach <[email protected]> Signed-off-by: Jeremy Fitzhardinge <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1c91fe1 commit 440a01a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

drivers/block/xen-blkfront.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/interrupt.h>
3939
#include <linux/blkdev.h>
4040
#include <linux/hdreg.h>
41+
#include <linux/cdrom.h>
4142
#include <linux/module.h>
4243

4344
#include <xen/xenbus.h>
@@ -153,6 +154,40 @@ static int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg)
153154
return 0;
154155
}
155156

157+
int blkif_ioctl(struct inode *inode, struct file *filep,
158+
unsigned command, unsigned long argument)
159+
{
160+
struct blkfront_info *info =
161+
inode->i_bdev->bd_disk->private_data;
162+
int i;
163+
164+
dev_dbg(&info->xbdev->dev, "command: 0x%x, argument: 0x%lx\n",
165+
command, (long)argument);
166+
167+
switch (command) {
168+
case CDROMMULTISESSION:
169+
dev_dbg(&info->xbdev->dev, "FIXME: support multisession CDs later\n");
170+
for (i = 0; i < sizeof(struct cdrom_multisession); i++)
171+
if (put_user(0, (char __user *)(argument + i)))
172+
return -EFAULT;
173+
return 0;
174+
175+
case CDROM_GET_CAPABILITY: {
176+
struct gendisk *gd = info->gd;
177+
if (gd->flags & GENHD_FL_CD)
178+
return 0;
179+
return -EINVAL;
180+
}
181+
182+
default:
183+
/*printk(KERN_ALERT "ioctl %08x not supported by Xen blkdev\n",
184+
command);*/
185+
return -EINVAL; /* same return as native Linux */
186+
}
187+
188+
return 0;
189+
}
190+
156191
/*
157192
* blkif_queue_request
158193
*
@@ -974,6 +1009,7 @@ static struct block_device_operations xlvbd_block_fops =
9741009
.open = blkif_open,
9751010
.release = blkif_release,
9761011
.getgeo = blkif_getgeo,
1012+
.ioctl = blkif_ioctl,
9771013
};
9781014

9791015

0 commit comments

Comments
 (0)