* 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:
@@ -396,25 +396,33 @@ 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) {
|
||||||
if (KDiskDevice *device = FindDevice(path)) {
|
for (int32 i = 0; i < 2; i++) {
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
if (ManagerLocker locker = this) {
|
if (ManagerLocker locker = this) {
|
||||||
if (KDiskDevice *device = FindDevice(id, deviceOnly)) {
|
if (KDiskDevice* device = FindDevice(id, deviceOnly)) {
|
||||||
device->Register();
|
device->Register();
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@@ -422,14 +430,15 @@ 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();
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@@ -437,25 +446,33 @@ 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) {
|
||||||
if (KPartition *partition = FindPartition(path)) {
|
for (int32 i = 0; i < 2; i++) {
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
if (ManagerLocker locker = this) {
|
if (ManagerLocker locker = this) {
|
||||||
if (KPartition *partition = FindPartition(id)) {
|
if (KPartition* partition = FindPartition(id)) {
|
||||||
partition->Register();
|
partition->Register();
|
||||||
return partition;
|
return partition;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user