* Try to create unknown devices before failing in RegisterDevice(), and

RegisterPartition().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27043 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-08-18 17:57:03 +00:00
parent ff388d5189
commit 5bfb703b6f
@@ -396,20 +396,28 @@ KDiskDeviceManager::FindFileDevice(const char *filePath)
return NULL; return NULL;
} }
// RegisterDevice
KDiskDevice* KDiskDevice*
KDiskDeviceManager::RegisterDevice(const char* path) KDiskDeviceManager::RegisterDevice(const char* path)
{ {
if (ManagerLocker locker = this) { if (ManagerLocker locker = this) {
for (int32 i = 0; i < 2; i++) {
if (KDiskDevice* device = FindDevice(path)) { if (KDiskDevice* device = FindDevice(path)) {
device->Register(); device->Register();
return device; return device;
} }
// if the device is not known yet, create it and try again
const char* leaf = strrchr(path, '/');
if (i == 0 && !strncmp(path, "/dev/disk", 9)
&& !strcmp(leaf + 1, "raw") && CreateDevice(path) < B_OK)
break;
}
} }
return NULL; return NULL;
} }
// RegisterDevice
KDiskDevice* KDiskDevice*
KDiskDeviceManager::RegisterDevice(partition_id id, bool deviceOnly) KDiskDeviceManager::RegisterDevice(partition_id id, bool deviceOnly)
{ {
@@ -422,12 +430,13 @@ KDiskDeviceManager::RegisterDevice(partition_id id, bool deviceOnly)
return NULL; return NULL;
} }
// RegisterNextDevice
KDiskDevice* KDiskDevice*
KDiskDeviceManager::RegisterNextDevice(int32* cookie) KDiskDeviceManager::RegisterNextDevice(int32* cookie)
{ {
if (!cookie) if (!cookie)
return NULL; return NULL;
if (ManagerLocker locker = this) { if (ManagerLocker locker = this) {
if (KDiskDevice* device = NextDevice(cookie)) { if (KDiskDevice* device = NextDevice(cookie)) {
device->Register(); device->Register();
@@ -437,20 +446,28 @@ KDiskDeviceManager::RegisterNextDevice(int32 *cookie)
return NULL; return NULL;
} }
// RegisterPartition
KPartition* KPartition*
KDiskDeviceManager::RegisterPartition(const char* path) KDiskDeviceManager::RegisterPartition(const char* path)
{ {
if (ManagerLocker locker = this) { if (ManagerLocker locker = this) {
for (int32 i = 0; i < 2; i++) {
if (KPartition* partition = FindPartition(path)) { if (KPartition* partition = FindPartition(path)) {
partition->Register(); partition->Register();
return partition; return partition;
} }
// if the device is not known yet, create it and try again
const char* leaf = strrchr(path, '/');
if (i == 0 && !strncmp(path, "/dev/disk", 9)
&& !strcmp(leaf + 1, "raw") && CreateDevice(path) < B_OK)
break;
}
} }
return NULL; return NULL;
} }
// RegisterPartition
KPartition* KPartition*
KDiskDeviceManager::RegisterPartition(partition_id id) KDiskDeviceManager::RegisterPartition(partition_id id)
{ {