Re: [Bug 7026] CD/DVD burning with USB writer doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I decided to do this by email instead of bugzilla so that it would be 
visible to everyone on the linux-scsi mailing list.

Re: http://bugzilla.kernel.org/show_bug.cgi?id=7026

To recap: Joerg Schilling needs to be able to retrieve the max_sectors 
value for a SCSI device's request queue.  Doing it via sysfs is rather 
clumsy, especially when only a file descriptor is available and not the 
device name.  He has asked for an ioctl interface to provide the 
information.

Is the patch below acceptable?

Alan Stern



Index: usb-2.6/block/scsi_ioctl.c
===================================================================
--- usb-2.6.orig/block/scsi_ioctl.c
+++ usb-2.6/block/scsi_ioctl.c
@@ -97,6 +97,11 @@ static int sg_set_reserved_size(request_
 	return 0;
 }
 
+static int sg_get_max_transfer_length(request_queue_t *q, int __user *p)
+{
+	return put_user(q->max_sectors << 9, p);
+}
+
 /*
  * will always return that we are ATAPI even for a real SCSI drive, I'm not
  * so sure this is worth doing anything about (why would you care??)
@@ -558,6 +563,9 @@ int scsi_cmd_ioctl(struct file *file, st
 		case SG_SET_RESERVED_SIZE:
 			err = sg_set_reserved_size(q, arg);
 			break;
+		case SG_GET_MAX_TRANSFER_LENGTH:
+			err = sg_get_max_transfer_length(q, arg);
+			break;
 		case SG_EMULATED_HOST:
 			err = sg_emulated_host(q, arg);
 			break;
Index: usb-2.6/drivers/scsi/sg.c
===================================================================
--- usb-2.6.orig/drivers/scsi/sg.c
+++ usb-2.6/drivers/scsi/sg.c
@@ -927,6 +927,11 @@ sg_ioctl(struct inode *inode, struct fil
 	case SG_GET_RESERVED_SIZE:
 		val = (int) sfp->reserve.bufflen;
 		return put_user(val, ip);
+	case SG_GET_MAX_TRANSFER_LENGTH:
+		if (sdp->detached || !sdp->device->request_queue)
+			return -ENODEV;
+		val = sdp->device->request_queue->max_sectors << 9;
+		return put_user(val, ip);
 	case SG_SET_COMMAND_Q:
 		result = get_user(val, ip);
 		if (result)
Index: usb-2.6/include/scsi/sg.h
===================================================================
--- usb-2.6.orig/include/scsi/sg.h
+++ usb-2.6/include/scsi/sg.h
@@ -219,6 +219,8 @@ typedef struct sg_req_info { /* used by 
 /* yields scsi midlevel's access_count for this SCSI device */
 #define SG_GET_ACCESS_COUNT 0x2289  
 
+/* Yields the SCSI device queue's max_sector value, in bytes */
+#define SG_GET_MAX_TRANSFER_LENGTH 0x228a
 
 #define SG_SCATTER_SZ (8 * 4096)
 /* Largest size (in bytes) a single scatter-gather list element can have.

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux