According to the kernel structure struct scsi_device
used by SCSI drivers (kernel 2.6.23):
http://lxr.linux.no/linux+v2.6.23/include/scsi/scsi_device.h#L49
Is there a reliable method to differentiate if the device is an USB device or a ATA device ?
For each
scsi_device
, you can get thescsi_host
that corresponds to it, and from there thescsi_host_template
, which is the vtable of the SCSI LLD. From there, you can look at the name field. drivers/scsi/storage/usb.c tells us the string should be "usb-storage".So, I think given 'sdev' as scsi_device pointer,
sdev->shost->hostt->name
should resolve to "usb-storage" in case it is a LUN from a USB mass storage device. From a design perspective, it might be considered a sort of a 'hack' to a accomplish the task this way, but without proper APIs that's the simplest way to go.