Do not base the device number on the device count. Fixes bug #4267.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32474 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-08-17 17:51:26 +00:00
parent 73c035dc11
commit 40b708f776
2 changed files with 11 additions and 2 deletions
@@ -748,12 +748,20 @@ usb_disk_device_added(usb_device newDevice, void **cookie)
}
mutex_lock(&gDeviceListLock);
device->device_number = 0;
disk_device *other = gDeviceList;
while (other != NULL) {
if (other->device_number >= device->device_number)
device->device_number = other->device_number + 1;
other = (disk_device *)other->link;
}
device->link = (void *)gDeviceList;
gDeviceList = device;
uint32 deviceNumber = gDeviceCount++;
gLunCount += device->lun_count;
for (uint8 i = 0; i < device->lun_count; i++)
sprintf(device->luns[i]->name, DEVICE_NAME, deviceNumber, i);
sprintf(device->luns[i]->name, DEVICE_NAME, device->device_number, i);
mutex_unlock(&gDeviceListLock);
TRACE("new device: 0x%08lx\n", (uint32)device);
@@ -32,6 +32,7 @@ typedef struct device_lun_s device_lun;
// holds common information about an attached device (pointed to by luns)
typedef struct disk_device_s {
usb_device device;
uint32 device_number;
bool removed;
uint32 open_count;
mutex lock;