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:
@@ -748,12 +748,20 @@ usb_disk_device_added(usb_device newDevice, void **cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&gDeviceListLock);
|
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;
|
device->link = (void *)gDeviceList;
|
||||||
gDeviceList = device;
|
gDeviceList = device;
|
||||||
uint32 deviceNumber = gDeviceCount++;
|
|
||||||
gLunCount += device->lun_count;
|
gLunCount += device->lun_count;
|
||||||
for (uint8 i = 0; i < device->lun_count; i++)
|
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);
|
mutex_unlock(&gDeviceListLock);
|
||||||
|
|
||||||
TRACE("new device: 0x%08lx\n", (uint32)device);
|
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)
|
// holds common information about an attached device (pointed to by luns)
|
||||||
typedef struct disk_device_s {
|
typedef struct disk_device_s {
|
||||||
usb_device device;
|
usb_device device;
|
||||||
|
uint32 device_number;
|
||||||
bool removed;
|
bool removed;
|
||||||
uint32 open_count;
|
uint32 open_count;
|
||||||
mutex lock;
|
mutex lock;
|
||||||
|
|||||||
Reference in New Issue
Block a user