From: Ian Campbell Date: Mon, 6 Jul 2009 13:54:52 +0000 (+0100) Subject: scsi_id: correct error handling in prepend_vendor_model X-Git-Tag: 174~909 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=c3eedf65671ea82704e68e4b69796d7067170815;hp=c3eedf65671ea82704e68e4b69796d7067170815;ds=sidebyside scsi_id: correct error handling in prepend_vendor_model The callers of prepend_vendor_model both expect < 0 to be returned on error and the index to be returned otherwise. However prepend_vendor_model actually returns 1 on error. Fix this by correctly returning -1. Older kernels (before e5b3cd42: "SCSI: sanitize INQUIRY strings") truncated the model field in sysfs (or propagated bad results from the target) to less than the expected/required 16 characters which meant that the SCSI id was mangled into: # /sbin/scsi_id -g -s /block/sdg S146cee20VIRTUAL-DISK when it should have been: # /sbin/scsi_id -g -s /block/sdg SIET VIRTUAL-DISK 146cee20 Notice how the serial number has been pasted over the vendor+model at index 1 instead of being added at the end. In the former case: # cat /sys/devices/platform/host5/session1/target5:0:0/5:0:0:1/model | od -t c -t x1 0000000 V I R T U A L - D I S K \n 56 49 52 54 55 41 4c 2d 44 49 53 4b 0a But it should have been: # cat /sys/devices/platform/host5/session1/target5:0:0/5:0:0:1/model | od -t c -t x1 0000000 V I R T U A L - D I S K 56 49 52 54 55 41 4c 2d 44 49 53 4b 20 20 20 20 0000020 \n 0a Signed-off-by: Ian Campbell ---