summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2011-04-19 01:21:52 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2011-04-19 01:21:52 +0000
commit47007d8bc8fd6b1e274d680e4a82815912162e2b (patch)
treed679629a9db6a25f548c1390bedc4ce866a58109 /sys
parent392ca6ca04b2a1744a54165898bbd3aab531919f (diff)
Include USB vendor and product ids when manufacturing a unique disk id
from a USB serial number, as recommended by the umass spec. ok dlg@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/umass_scsi.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/dev/usb/umass_scsi.c b/sys/dev/usb/umass_scsi.c
index a9f3eba18ed..95706576338 100644
--- a/sys/dev/usb/umass_scsi.c
+++ b/sys/dev/usb/umass_scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umass_scsi.c,v 1.32 2011/04/06 15:16:54 dlg Exp $ */
+/* $OpenBSD: umass_scsi.c,v 1.33 2011/04/19 01:21:51 matthew Exp $ */
/* $NetBSD: umass_scsipi.c,v 1.9 2003/02/16 23:14:08 augustss Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -179,10 +179,16 @@ umass_scsi_probe(struct scsi_link *link)
return (0);
usbd_fill_deviceinfo(sc->sc_udev, &udi, 1);
- if (strlen(udi.udi_serial) > 0) {
- link->id = devid_alloc(DEVID_SERIAL, DEVID_F_PRINT,
- min(strlen(udi.udi_serial), sizeof(udi.udi_serial)),
- udi.udi_serial);
+ if (udi.udi_serial[0] != '\0') {
+ char buf[USB_MAX_STRING_LEN + 16];
+ size_t len;
+
+ len = snprintf(buf, sizeof(buf), "%04x%04x:%.*s",
+ udi.udi_vendorNo, udi.udi_productNo,
+ sizeof(udi.udi_serial), udi.udi_serial);
+ KASSERT(len < sizeof(buf));
+
+ link->id = devid_alloc(DEVID_SERIAL, DEVID_F_PRINT, len, buf);
}
return (0);