All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.5.53 SCSI_IOCTL_GET_IDLUN+GET_BUS_NUMBER revisited
@ 2002-12-28  0:24 Douglas Gilbert
  0 siblings, 0 replies; only message in thread
From: Douglas Gilbert @ 2002-12-28  0:24 UTC (permalink / raw)
  To: linux-scsi; +Cc: axboe

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]

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).

Doug Gilbert

[-- Attachment #2: sd_sr_2553_ioctl.diff --]
[-- Type: text/plain, Size: 1417 bytes --]

--- linux/drivers/scsi/sd.c	2002-12-24 18:12:54.000000000 +1100
+++ linux/drivers/scsi/sd.c2553ioctl	2002-12-28 09:25:13.000000000 +1100
@@ -537,9 +537,20 @@
 		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);
 }
 
--- linux/drivers/scsi/sr.c	2002-12-24 18:12:54.000000000 +1100
+++ linux/drivers/scsi/sr.c2553ioctl	2002-12-28 09:36:19.000000000 +1100
@@ -434,6 +434,17 @@
 			  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);
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-28  0:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-28  0:24 [PATCH] 2.5.53 SCSI_IOCTL_GET_IDLUN+GET_BUS_NUMBER revisited Douglas Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.