diff options
author | Ian Campbell <Ian.Campbell@citrix.com> | 2009-07-06 14:54:52 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-07-06 16:21:08 +0200 |
commit | c3eedf65671ea82704e68e4b69796d7067170815 (patch) | |
tree | 96829bcf2a1cd009bf2f90f09786d35ff2680866 /extras/scsi_id/scsi_serial.c | |
parent | 739ce84bfae2734e741a7fe94d4fa8af4903c050 (diff) |
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 <ijc@hellion.org.uk>
Diffstat (limited to 'extras/scsi_id/scsi_serial.c')
-rw-r--r-- | extras/scsi_id/scsi_serial.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c index 68bed08241..4248829180 100644 --- a/extras/scsi_id/scsi_serial.c +++ b/extras/scsi_id/scsi_serial.c @@ -467,7 +467,7 @@ static int prepend_vendor_model(struct udev *udev, if (ind != (VENDOR_LENGTH + MODEL_LENGTH)) { info(udev, "%s: expected length %d, got length %d\n", dev_scsi->kernel, (VENDOR_LENGTH + MODEL_LENGTH), ind); - return 1; + return -1; } return ind; } |