Commit 1f3e6f50 authored by Douglas Gilbert's avatar Douglas Gilbert Committed by Christoph Hellwig

2.5.53 SCSI_IOCTL_GET_IDLUN+GET_BUS_NUMBER revisited

Currently for block devices both the SCSI_IOCTL_GET_IDLUN and 
SCSI_IOCTL_GET_BUS_NUMBER ioctls yield the value 0 (type: int).

Various applications that utilize the sg driver use these ioctls
to work out the relationship between sg devices and their higher
level counterparts in the sd, sr, st and osst drivers. Examples
that spring to mind are cdrecord, cdparanoia, SANE and sg_utils.

This has been discussed in an earlier threaded started by me:
http://marc.theaimsgroup.com/?l=linux-scsi&m=103967899608891&w=2
in which my patch removed the ioctls in question from the block
level. This broke non-scsi block devices that used applications
that thought they were talking to an sg device **.

The attachment fine tunes the original patch: for scsi block
devices (i.e. owned by the sd or sr drivers) these 2 ioctls
are redirected to the scsi mid level; for non-scsi block
devices they will yield the value as 0 as they do now in
lk 2.5.53 .


** This "yield 0" strategy will come unstuck when 2 or more
cd writers (for example) are connected to the same box.
Hence to be well formed, these ioctls (together) should
produce unique tuples for each device (be they ATA(PI) or
SCSI).
parent 148593a5
......@@ -537,9 +537,20 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
return sd_hdio_getgeo(bdev, (struct hd_geometry *)arg);
}
error = scsi_cmd_ioctl(bdev, cmd, arg);
if (error != -ENOTTY)
return error;
/*
* Send SCSI addressing ioctls directly to mid level, send other
* ioctls to block level and then onto mid level if they can't be
* resolved.
*/
switch (cmd) {
case SCSI_IOCTL_GET_IDLUN:
case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_ioctl(sdp, cmd, (void *)arg);
default:
error = scsi_cmd_ioctl(bdev, cmd, arg);
if (error != -ENOTTY)
return error;
}
return scsi_ioctl(sdp, cmd, (void *)arg);
}
......
......@@ -434,6 +434,17 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
unsigned long arg)
{
struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
struct scsi_device *sdev = cd->device;
/*
* Send SCSI addressing ioctls directly to mid level, send other
* ioctls to cdrom/block level.
*/
switch (cmd) {
case SCSI_IOCTL_GET_IDLUN:
case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_ioctl(sdev, cmd, (void *)arg);
}
return cdrom_ioctl(&cd->cdi, inode, cmd, arg);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment