In early boot mode, open_module_list() is not able to find everything we
want it to find; therefore, we're now using get_next_loaded_module_name(). Added a temporary suffix to the FS DDM modules (disk_device/v1) - they might get merged with the standard FS interface modules. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9503 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
// KDiskDeviceManager.cpp
|
/*
|
||||||
|
** Copyright 2003-2004, Ingo Weinhold, [email protected]. All rights reserved.
|
||||||
|
** Distributed under the terms of the Haiku License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
@@ -33,24 +37,17 @@
|
|||||||
#define DBG(x) x
|
#define DBG(x) x
|
||||||
#define OUT dprintf
|
#define OUT dprintf
|
||||||
|
|
||||||
|
|
||||||
// directories for partitioning and file system modules
|
// directories for partitioning and file system modules
|
||||||
static const char *kPartitioningSystemPrefix = "partitioning_systems";
|
static const char *kPartitioningSystemPrefix = "partitioning_systems";
|
||||||
static const char *kFileSystemPrefix = "file_systems";
|
static const char *kFileSystemPrefix = "file_systems";
|
||||||
|
static const char *kFileSystemDiskDeviceSuffix = "/disk_device/v1";
|
||||||
|
|
||||||
|
|
||||||
// singleton instance
|
// singleton instance
|
||||||
KDiskDeviceManager *KDiskDeviceManager::sDefaultManager = NULL;
|
KDiskDeviceManager *KDiskDeviceManager::sDefaultManager = NULL;
|
||||||
|
|
||||||
|
|
||||||
// is_active_job_status
|
|
||||||
static
|
|
||||||
bool
|
|
||||||
is_active_job_status(uint32 status)
|
|
||||||
{
|
|
||||||
return (status == B_DISK_DEVICE_JOB_SCHEDULED
|
|
||||||
|| status == B_DISK_DEVICE_JOB_IN_PROGRESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPartitionID
|
// GetPartitionID
|
||||||
struct GetPartitionID {
|
struct GetPartitionID {
|
||||||
inline partition_id operator()(const KPartition *partition) const
|
inline partition_id operator()(const KPartition *partition) const
|
||||||
@@ -108,7 +105,34 @@ struct KDiskDeviceManager::JobMap : VectorMap<disk_job_id, KDiskDeviceJob*,
|
|||||||
struct KDiskDeviceManager::JobQueueVector : Vector<KDiskDeviceJobQueue*> {};
|
struct KDiskDeviceManager::JobQueueVector : Vector<KDiskDeviceJobQueue*> {};
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
static bool
|
||||||
|
is_active_job_status(uint32 status)
|
||||||
|
{
|
||||||
|
return (status == B_DISK_DEVICE_JOB_SCHEDULED
|
||||||
|
|| status == B_DISK_DEVICE_JOB_IN_PROGRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_fs_disk_device(const char *module)
|
||||||
|
{
|
||||||
|
size_t prefixLength = strlen(kFileSystemPrefix);
|
||||||
|
if (strncmp(module, kFileSystemPrefix, prefixLength))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t suffixLength = strlen(kFileSystemDiskDeviceSuffix);
|
||||||
|
size_t length = strlen(module);
|
||||||
|
|
||||||
|
if (length <= suffixLength + prefixLength)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !strcmp(module + length - suffixLength, kFileSystemDiskDeviceSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
KDiskDeviceManager::KDiskDeviceManager()
|
KDiskDeviceManager::KDiskDeviceManager()
|
||||||
: fLock("disk device manager"),
|
: fLock("disk device manager"),
|
||||||
fDevices(new(nothrow) DeviceMap),
|
fDevices(new(nothrow) DeviceMap),
|
||||||
@@ -121,33 +145,34 @@ KDiskDeviceManager::KDiskDeviceManager()
|
|||||||
{
|
{
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
// add partitioning systems
|
|
||||||
if (void *list = open_module_list(kPartitioningSystemPrefix)) {
|
// We are in early boot mode, so open_module_list() won't find what
|
||||||
char moduleName[B_PATH_NAME_LENGTH];
|
// we're looking for; we need to use get_next_loaded_module_name()
|
||||||
for (size_t bufferSize = sizeof(moduleName);
|
// instead.
|
||||||
read_next_module_name(list, moduleName, &bufferSize) == B_OK;
|
|
||||||
bufferSize = sizeof(moduleName)) {
|
uint32 cookie = 0;
|
||||||
DBG(OUT("partitioning system: %s\n", moduleName));
|
size_t partitioningPrefixLength = strlen(kPartitioningSystemPrefix);
|
||||||
_AddPartitioningSystem(moduleName);
|
|
||||||
|
while (true) {
|
||||||
|
char name[B_PATH_NAME_LENGTH];
|
||||||
|
size_t nameLength = sizeof(name);
|
||||||
|
if (get_next_loaded_module_name(&cookie, name, &nameLength) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!strncmp(name, kPartitioningSystemPrefix, partitioningPrefixLength)) {
|
||||||
|
DBG(OUT("partitioning system: %s\n", name));
|
||||||
|
_AddPartitioningSystem(name);
|
||||||
|
} else if (is_fs_disk_device(name)) {
|
||||||
|
DBG(OUT("file system: %s\n", name));
|
||||||
|
_AddFileSystem(name);
|
||||||
}
|
}
|
||||||
close_module_list(list);
|
|
||||||
}
|
}
|
||||||
// add file systems
|
|
||||||
if (void *list = open_module_list(kFileSystemPrefix)) {
|
DBG(OUT("number of disk systems: %ld\n", CountDiskSystems()));
|
||||||
char moduleName[B_PATH_NAME_LENGTH];
|
|
||||||
for (size_t bufferSize = sizeof(moduleName);
|
|
||||||
read_next_module_name(list, moduleName, &bufferSize) == B_OK;
|
|
||||||
bufferSize = sizeof(moduleName)) {
|
|
||||||
DBG(OUT("file system: %s\n", moduleName));
|
|
||||||
_AddFileSystem(moduleName);
|
|
||||||
}
|
|
||||||
close_module_list(list);
|
|
||||||
}
|
|
||||||
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
KDiskDeviceManager::~KDiskDeviceManager()
|
KDiskDeviceManager::~KDiskDeviceManager()
|
||||||
{
|
{
|
||||||
// TODO: terminate and remove all jobs
|
// TODO: terminate and remove all jobs
|
||||||
|
|||||||
Reference in New Issue
Block a user