I fail the USB SCSI device only if it does not contain VPD_PG80.. and then it keeps its serial as it won't support SCSI commands anyway. This is better because it keeps compatibility with SCSI protocol, for USB drives supporting not only SCSI commands but also SCSI protocol itself:
Example for a memory stick (only SCSI commands):
$ sudo sg_inq --export --inhex=/sys/block/sdc/device/vpd_pg80 --raw
unable to open binary file /sys/block/sdc/device/vpd_pg80: No such file or directory
This will make udev to stop all other rules (and stop udev for running another INQ directly to the device, which would fail).
Alright, I found a much better solution for this:
# SCSI EVPD page 0x80 values ="sd*[! 0-9]|sr* ", ENV{ID_SCSI}=="1", IMPORT{ program} ="/usr/ bin/sg_ inq --export --inhex= /sys/block/ $kernel/ device/ vpd_pg80 --raw", ENV{ID_SCSI_SN}="1" ="sd*[! 0-9]|sr* ", ENV{ID_ SCSI_SN} !="1" GOTO="sg3_ utils_id_ end" ="sd*[! 0-9]|sr* ", ENV{ID_SCSI}=="1", ENV{ID_ SCSI_SN} !="1", IMPORT{ program} ="/usr/ bin/sg_ inq --export --page=sn $tempnode", ENV{ID_SCSI_SN}="1"
KERNEL=
KERNEL=
KERNEL=
I fail the USB SCSI device only if it does not contain VPD_PG80.. and then it keeps its serial as it won't support SCSI commands anyway. This is better because it keeps compatibility with SCSI protocol, for USB drives supporting not only SCSI commands but also SCSI protocol itself:
Example for a memory stick (only SCSI commands):
$ sudo sg_inq --export --inhex= /sys/block/ sdc/device/ vpd_pg80 --raw sdc/device/ vpd_pg80: No such file or directory
unable to open binary file /sys/block/
This will make udev to stop all other rules (and stop udev for running another INQ directly to the device, which would fail).
Now, for a device that supports SCSI protocol:
$ sudo sg_inq --export --inhex= /sys/block/ sdb/device/ vpd_pg80 --raw SERIAL= NA7EMXLG
SCSI_IDENT_
then udev will keep running all other udev rules (and get a new SCSI_SERIAL_SN, for example).