+ // Zero size indicates some form of critical error
+ if( !info->BlockCount ) {
+ Log_Error("USB MSC", "Device did not report a valid size");
+ USB_SetDeviceDataPtr(Dev, NULL);
+ free(info);
+ return ;
+ }
+
+ // Create device name from Vendor ID, Device ID and Serial Number
+ Uint16 vendor, devid;
+ char *serial_number;
+ USB_GetDeviceVendor(Dev, &vendor, &devid);
+ serial_number = USB_GetSerialNumber(Dev);
+ if( !serial_number ) {
+ // No serial number - this breaks spec, but it's easy to handle
+ Log_Warning("USB MSC", "Device does not have a serial number, using a random one");
+ serial_number = malloc(4+8+1);
+ sprintf(serial_number, "rand%08x", rand());
+ }
+ char name[4 + 4 + 1 + 4 + 1 + strlen(serial_number) + 1];
+ sprintf(name, "usb-%04x:%04x-%s", vendor, devid, serial_number);
+ free(serial_number);
+
+ // Pass the buck to LVM
+ LOG("Device '%s' has 0x%llx blocks of 0x%x bytes", name, info->BlockCount, info->BlockSize);
+ LVM_AddVolume(vt, name, Dev, info->BlockSize, info->BlockCount);