axeld+bonefish:
* Refactored RescanDiskSystems(). Pulled out a function _RescanDiskSystems() that scans for either file or partitioning systems. RescanDiskSystems(), which scanned for file systems only before, is used from the constructor as well (open_module_list() works in the early boot process since a while). * Made InitialDeviceScan() and partition scanning safe to be called a second time. We call it directly after the kernel has mounted the boot volume, now, so that additional disk systems from the boot volume have a chance to recognize previously unrecognized partitions. This is a temporary change only; later the disk device manager shall automatically find out when new disk systems/devices/whatever are available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21655 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -131,34 +131,7 @@ KDiskDeviceManager::KDiskDeviceManager()
|
|||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// We are in early boot mode, so open_module_list() won't find what
|
RescanDiskSystems();
|
||||||
// we're looking for; we need to use get_next_loaded_module_name()
|
|
||||||
// instead.
|
|
||||||
|
|
||||||
uint32 cookie = 0;
|
|
||||||
size_t partitioningPrefixLength = strlen(kPartitioningSystemPrefix);
|
|
||||||
size_t filePrefixLength = strlen(kFileSystemPrefix);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
KPath name;
|
|
||||||
if (name.InitCheck() != B_OK)
|
|
||||||
break;
|
|
||||||
size_t nameLength = name.BufferSize();
|
|
||||||
if (get_next_loaded_module_name(&cookie, name.LockBuffer(),
|
|
||||||
&nameLength) != B_OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
name.UnlockBuffer();
|
|
||||||
|
|
||||||
if (!strncmp(name.Path(), kPartitioningSystemPrefix,
|
|
||||||
partitioningPrefixLength)) {
|
|
||||||
DBG(OUT("partitioning system: %s\n", name.Path()));
|
|
||||||
_AddPartitioningSystem(name.Path());
|
|
||||||
} else if (!strncmp(name.Path(), kFileSystemPrefix, filePrefixLength)) {
|
|
||||||
DBG(OUT("file system: %s\n", name.Path()));
|
|
||||||
_AddFileSystem(name.Path());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DBG(OUT("number of disk systems: %ld\n", CountDiskSystems()));
|
DBG(OUT("number of disk systems: %ld\n", CountDiskSystems()));
|
||||||
// TODO: Watch the disk systems and the relevant directories.
|
// TODO: Watch the disk systems and the relevant directories.
|
||||||
@@ -929,27 +902,49 @@ KDiskDeviceManager::InitialDeviceScan()
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
//RescanDiskSystems
|
// _RescanDiskSystems
|
||||||
|
status_t
|
||||||
|
KDiskDeviceManager::_RescanDiskSystems(bool fileSystems)
|
||||||
|
{
|
||||||
|
void *cookie = open_module_list(fileSystems
|
||||||
|
? kFileSystemPrefix : kPartitioningSystemPrefix);
|
||||||
|
if (cookie == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
KPath name;
|
||||||
|
if (name.InitCheck() != B_OK)
|
||||||
|
break;
|
||||||
|
size_t nameLength = name.BufferSize();
|
||||||
|
if (read_next_module_name(cookie, name.LockBuffer(),
|
||||||
|
&nameLength) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
name.UnlockBuffer();
|
||||||
|
|
||||||
|
if (FindDiskSystem(name.Path()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fileSystems) {
|
||||||
|
DBG(OUT("file system: %s\n", name.Path()));
|
||||||
|
_AddFileSystem(name.Path());
|
||||||
|
} else {
|
||||||
|
DBG(OUT("partitioning system: %s\n", name.Path()));
|
||||||
|
_AddPartitioningSystem(name.Path());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close_module_list(cookie);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RescanDiskSystems
|
||||||
status_t
|
status_t
|
||||||
KDiskDeviceManager::RescanDiskSystems()
|
KDiskDeviceManager::RescanDiskSystems()
|
||||||
{
|
{
|
||||||
// load file systems list
|
// rescan for partitioning and file systems
|
||||||
void *cookie = open_module_list(kFileSystemPrefix);
|
_RescanDiskSystems(false);
|
||||||
|
_RescanDiskSystems(true);
|
||||||
while (true) {
|
|
||||||
char name[B_FILE_NAME_LENGTH];
|
|
||||||
size_t nameLength = sizeof(name);
|
|
||||||
module_info *module;
|
|
||||||
|
|
||||||
if (read_next_module_name(cookie, name, &nameLength) != B_OK)
|
|
||||||
break;
|
|
||||||
if (FindDiskSystem(name))
|
|
||||||
continue;
|
|
||||||
_AddFileSystem(name);
|
|
||||||
}
|
|
||||||
close_module_list(cookie);
|
|
||||||
|
|
||||||
// TODO rescan partition tree for unrecognized partitions
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -1161,6 +1156,11 @@ DBG(OUT("KDiskDeviceManager::_Scan(%s)\n", path));
|
|||||||
int32 leafLen = strlen("/raw");
|
int32 leafLen = strlen("/raw");
|
||||||
if (len <= leafLen || strcmp(path + len - leafLen, "/raw"))
|
if (len <= leafLen || strcmp(path + len - leafLen, "/raw"))
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
if (FindDevice(path) != NULL) {
|
||||||
|
// we already know this device
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
DBG(OUT(" found device: %s\n", path));
|
DBG(OUT(" found device: %s\n", path));
|
||||||
// create a KDiskDevice for it
|
// create a KDiskDevice for it
|
||||||
KDiskDevice *device = new(nothrow) KDiskDevice;
|
KDiskDevice *device = new(nothrow) KDiskDevice;
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ KScanPartitionJob::_ScanPartition(KPartition *partition)
|
|||||||
// the partition's device must be write-locked
|
// the partition's device must be write-locked
|
||||||
if (!partition)
|
if (!partition)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
if (partition->DiskSystem() != NULL) {
|
||||||
|
// TODO: this is more or less a hack to prevent rescanning a partition
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
DBG(
|
DBG(
|
||||||
KPath partitionPath;
|
KPath partitionPath;
|
||||||
|
|||||||
@@ -508,5 +508,8 @@ vfs_mount_boot_file_system(kernel_args *args)
|
|||||||
// search for other disk systems
|
// search for other disk systems
|
||||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||||
manager->RescanDiskSystems();
|
manager->RescanDiskSystems();
|
||||||
|
manager->InitialDeviceScan();
|
||||||
|
// TODO: later, the DDM should notice when there are new
|
||||||
|
// partitions/devices available
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user