@@ -844,6 +844,19 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
*bflags |= BLIST_NOREPORTLUN;
}
+ if (sdev->type == TYPE_SCANNER) {
+ sdev->request_queue->cmd_filter =
+ kzalloc(sizeof(struct blk_cmd_filter), GFP_KERNEL);
+
+ if (!sdev->request_queue->cmd_filter)
+ return SCSI_SCAN_NO_RESPONSE;
+
+ memset(sdev->request_queue->cmd_filter->read_ok, 0xFF,
+ sizeof(sdev->request_queue->cmd_filter->read_ok));
+ memset(sdev->request_queue->cmd_filter->write_ok, 0xFF,
+ sizeof(sdev->request_queue->cmd_filter->write_ok));
+ }
+
/*
* For a peripheral qualifier (PQ) value of 1 (001b), the SCSI
* spec says: The device server is capable of supporting the
@@ -242,9 +242,6 @@ static int sg_allow_access(struct file *filp, unsigned char *cmd)
struct sg_fd *sfp = filp->private_data;
struct scsi_device *device = sfp->parentdp->device;
- if (device->type == TYPE_SCANNER)
- return 0;
-
return blk_verify_command(device->request_queue, cmd, filp->f_mode);
}
Any command is allowed for scanners when /dev/sg is used. Reimplement this using customizable command filters, so that the sysfs knobs will work in this case, too. Cc: linux-scsi@vger.kernel.org Cc: Hannes Reinecke <hare@suse.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: James Bottomley <James.Bottomley@hansenpartnership.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- drivers/scsi/scsi_scan.c | 13 +++++++++++++ drivers/scsi/sg.c | 3 --- 2 files changed, 13 insertions(+), 3 deletions(-)