* Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27114 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,7 +53,6 @@ static const char *kFileSystemPrefix = "file_systems";
|
||||
KDiskDeviceManager* KDiskDeviceManager::sDefaultManager = NULL;
|
||||
|
||||
|
||||
// GetPartitionID
|
||||
struct GetPartitionID {
|
||||
inline partition_id operator()(const KPartition* partition) const
|
||||
{
|
||||
@@ -61,7 +60,7 @@ struct GetPartitionID {
|
||||
}
|
||||
};
|
||||
|
||||
// GetDiskSystemID
|
||||
|
||||
struct GetDiskSystemID {
|
||||
inline disk_system_id operator()(const KDiskSystem* system) const
|
||||
{
|
||||
@@ -70,26 +69,25 @@ struct GetDiskSystemID {
|
||||
};
|
||||
|
||||
|
||||
// PartitionMap
|
||||
struct KDiskDeviceManager::PartitionMap : VectorMap<partition_id, KPartition*,
|
||||
VectorMapEntryStrategy::ImplicitKey<partition_id, KPartition*,
|
||||
GetPartitionID> > {
|
||||
};
|
||||
|
||||
// DeviceMap
|
||||
|
||||
struct KDiskDeviceManager::DeviceMap : VectorMap<partition_id, KDiskDevice*,
|
||||
VectorMapEntryStrategy::ImplicitKey<partition_id, KDiskDevice*,
|
||||
GetPartitionID> > {
|
||||
};
|
||||
|
||||
// DiskSystemMap
|
||||
|
||||
struct KDiskDeviceManager::DiskSystemMap : VectorMap<disk_system_id,
|
||||
KDiskSystem*,
|
||||
VectorMapEntryStrategy::ImplicitKey<disk_system_id, KDiskSystem*,
|
||||
GetDiskSystemID> > {
|
||||
};
|
||||
|
||||
// PartitionSet
|
||||
|
||||
struct KDiskDeviceManager::PartitionSet : VectorSet<KPartition*> {
|
||||
};
|
||||
|
||||
@@ -118,11 +116,11 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// DeviceWatcher
|
||||
class KDiskDeviceManager::DeviceWatcher : public NotificationListener {
|
||||
public:
|
||||
DeviceWatcher(KDiskDeviceManager* manager)
|
||||
: fManager(manager)
|
||||
:
|
||||
fManager(manager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -230,6 +228,7 @@ KDiskDeviceManager::~KDiskDeviceManager()
|
||||
PartitionRegistrar _(device);
|
||||
_RemoveDevice(device);
|
||||
}
|
||||
|
||||
// some sanity checks
|
||||
if (fPartitions->Count() > 0) {
|
||||
DBG(OUT("WARNING: There are still %ld unremoved partitions!\n",
|
||||
@@ -264,22 +263,20 @@ KDiskDeviceManager::~KDiskDeviceManager()
|
||||
delete fObsoletePartitions;
|
||||
}
|
||||
|
||||
// InitCheck
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::InitCheck() const
|
||||
{
|
||||
if (!fPartitions || !fDevices || !fDiskSystems || !fObsoletePartitions)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return (fLock.Sem() >= 0 ? B_OK : fLock.Sem());
|
||||
return fLock.Sem() >= 0 ? B_OK : fLock.Sem();
|
||||
}
|
||||
|
||||
|
||||
/** This creates the system's default DiskDeviceManager.
|
||||
* The creation is not thread-safe, and shouldn't be done
|
||||
* more than once.
|
||||
/*! This creates the system's default DiskDeviceManager.
|
||||
The creation is not thread-safe, and shouldn't be done more than once.
|
||||
*/
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::CreateDefault()
|
||||
{
|
||||
@@ -294,11 +291,9 @@ KDiskDeviceManager::CreateDefault()
|
||||
}
|
||||
|
||||
|
||||
/** This deletes the default DiskDeviceManager. The
|
||||
* deletion is not thread-safe either, you should
|
||||
* make sure that it's called only once.
|
||||
/*! This deletes the default DiskDeviceManager. The deletion is not
|
||||
thread-safe either, you should make sure that it's called only once.
|
||||
*/
|
||||
|
||||
void
|
||||
KDiskDeviceManager::DeleteDefault()
|
||||
{
|
||||
@@ -306,28 +301,28 @@ KDiskDeviceManager::DeleteDefault()
|
||||
sDefaultManager = NULL;
|
||||
}
|
||||
|
||||
// Default
|
||||
|
||||
KDiskDeviceManager*
|
||||
KDiskDeviceManager::Default()
|
||||
{
|
||||
return sDefaultManager;
|
||||
}
|
||||
|
||||
// Lock
|
||||
|
||||
bool
|
||||
KDiskDeviceManager::Lock()
|
||||
{
|
||||
return fLock.Lock();
|
||||
}
|
||||
|
||||
// Unlock
|
||||
|
||||
void
|
||||
KDiskDeviceManager::Unlock()
|
||||
{
|
||||
fLock.Unlock();
|
||||
}
|
||||
|
||||
// FindDevice
|
||||
|
||||
KDiskDevice*
|
||||
KDiskDeviceManager::FindDevice(const char* path)
|
||||
{
|
||||
@@ -338,7 +333,7 @@ KDiskDeviceManager::FindDevice(const char *path)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FindDevice
|
||||
|
||||
KDiskDevice*
|
||||
KDiskDeviceManager::FindDevice(partition_id id, bool deviceOnly)
|
||||
{
|
||||
@@ -350,7 +345,7 @@ KDiskDeviceManager::FindDevice(partition_id id, bool deviceOnly)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FindPartition
|
||||
|
||||
KPartition*
|
||||
KDiskDeviceManager::FindPartition(const char* path)
|
||||
{
|
||||
@@ -359,9 +354,9 @@ KDiskDeviceManager::FindPartition(const char *path)
|
||||
if (partitionPath.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
|
||||
for (PartitionMap::Iterator it = fPartitions->Begin();
|
||||
it != fPartitions->End(); ++it) {
|
||||
KPartition *partition = it->Value();
|
||||
for (PartitionMap::Iterator iterator = fPartitions->Begin();
|
||||
iterator != fPartitions->End(); ++iterator) {
|
||||
KPartition* partition = iterator->Value();
|
||||
if (partition->GetPath(&partitionPath) == B_OK
|
||||
&& partitionPath == path) {
|
||||
return partition;
|
||||
@@ -371,18 +366,18 @@ KDiskDeviceManager::FindPartition(const char *path)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FindPartition
|
||||
|
||||
KPartition*
|
||||
KDiskDeviceManager::FindPartition(partition_id id)
|
||||
{
|
||||
PartitionMap::Iterator it = fPartitions->Find(id);
|
||||
if (it != fPartitions->End())
|
||||
return it->Value();
|
||||
PartitionMap::Iterator iterator = fPartitions->Find(id);
|
||||
if (iterator != fPartitions->End())
|
||||
return iterator->Value();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FindFileDevice
|
||||
|
||||
KFileDiskDevice*
|
||||
KDiskDeviceManager::FindFileDevice(const char* filePath)
|
||||
{
|
||||
@@ -480,7 +475,7 @@ KDiskDeviceManager::RegisterPartition(partition_id id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// RegisterFileDevice
|
||||
|
||||
KFileDiskDevice*
|
||||
KDiskDeviceManager::RegisterFileDevice(const char* filePath)
|
||||
{
|
||||
@@ -493,7 +488,7 @@ KDiskDeviceManager::RegisterFileDevice(const char *filePath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ReadLockDevice
|
||||
|
||||
KDiskDevice*
|
||||
KDiskDeviceManager::ReadLockDevice(partition_id id, bool deviceOnly)
|
||||
{
|
||||
@@ -508,7 +503,7 @@ KDiskDeviceManager::ReadLockDevice(partition_id id, bool deviceOnly)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// WriteLockDevice
|
||||
|
||||
KDiskDevice*
|
||||
KDiskDeviceManager::WriteLockDevice(partition_id id, bool deviceOnly)
|
||||
{
|
||||
@@ -523,7 +518,7 @@ KDiskDeviceManager::WriteLockDevice(partition_id id, bool deviceOnly)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ReadLockPartition
|
||||
|
||||
KPartition*
|
||||
KDiskDeviceManager::ReadLockPartition(partition_id id)
|
||||
{
|
||||
@@ -552,7 +547,7 @@ KDiskDeviceManager::ReadLockPartition(partition_id id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// WriteLockPartition
|
||||
|
||||
KPartition*
|
||||
KDiskDeviceManager::WriteLockPartition(partition_id id)
|
||||
{
|
||||
@@ -582,7 +577,6 @@ KDiskDeviceManager::WriteLockPartition(partition_id id)
|
||||
}
|
||||
|
||||
|
||||
// ScanPartition
|
||||
status_t
|
||||
KDiskDeviceManager::ScanPartition(KPartition* partition)
|
||||
{
|
||||
@@ -671,7 +665,6 @@ KDiskDeviceManager::DeleteDevice(const char *path)
|
||||
}
|
||||
|
||||
|
||||
// CreateFileDevice
|
||||
partition_id
|
||||
KDiskDeviceManager::CreateFileDevice(const char* filePath, bool* newlyCreated)
|
||||
{
|
||||
@@ -729,7 +722,7 @@ KDiskDeviceManager::CreateFileDevice(const char *filePath, bool* newlyCreated)
|
||||
return error;
|
||||
}
|
||||
|
||||
// DeleteFileDevice
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::DeleteFileDevice(const char* filePath)
|
||||
{
|
||||
@@ -743,7 +736,7 @@ KDiskDeviceManager::DeleteFileDevice(const char *filePath)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// DeleteFileDevice
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::DeleteFileDevice(partition_id id)
|
||||
{
|
||||
@@ -759,14 +752,14 @@ KDiskDeviceManager::DeleteFileDevice(partition_id id)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// CountDevices
|
||||
|
||||
int32
|
||||
KDiskDeviceManager::CountDevices()
|
||||
{
|
||||
return fDevices->Count();
|
||||
}
|
||||
|
||||
// NextDevice
|
||||
|
||||
KDiskDevice*
|
||||
KDiskDeviceManager::NextDevice(int32* cookie)
|
||||
{
|
||||
@@ -781,14 +774,14 @@ KDiskDeviceManager::NextDevice(int32 *cookie)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// PartitionAdded
|
||||
|
||||
bool
|
||||
KDiskDeviceManager::PartitionAdded(KPartition* partition)
|
||||
{
|
||||
return (partition && fPartitions->Put(partition->ID(), partition) == B_OK);
|
||||
return partition && fPartitions->Put(partition->ID(), partition) == B_OK;
|
||||
}
|
||||
|
||||
// PartitionRemoved
|
||||
|
||||
bool
|
||||
KDiskDeviceManager::PartitionRemoved(KPartition* partition)
|
||||
{
|
||||
@@ -803,7 +796,7 @@ KDiskDeviceManager::PartitionRemoved(KPartition *partition)
|
||||
return false;
|
||||
}
|
||||
|
||||
// DeletePartition
|
||||
|
||||
bool
|
||||
KDiskDeviceManager::DeletePartition(KPartition* partition)
|
||||
{
|
||||
@@ -818,7 +811,6 @@ KDiskDeviceManager::DeletePartition(KPartition *partition)
|
||||
}
|
||||
|
||||
|
||||
// FindDiskSystem
|
||||
KDiskSystem*
|
||||
KDiskDeviceManager::FindDiskSystem(const char* name, bool byPrettyName)
|
||||
{
|
||||
@@ -834,7 +826,7 @@ KDiskDeviceManager::FindDiskSystem(const char *name, bool byPrettyName)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FindDiskSystem
|
||||
|
||||
KDiskSystem*
|
||||
KDiskDeviceManager::FindDiskSystem(disk_system_id id)
|
||||
{
|
||||
@@ -844,19 +836,20 @@ KDiskDeviceManager::FindDiskSystem(disk_system_id id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// CountDiskSystems
|
||||
|
||||
int32
|
||||
KDiskDeviceManager::CountDiskSystems()
|
||||
{
|
||||
return fDiskSystems->Count();
|
||||
}
|
||||
|
||||
// NextDiskSystem
|
||||
|
||||
KDiskSystem*
|
||||
KDiskDeviceManager::NextDiskSystem(int32* cookie)
|
||||
{
|
||||
if (!cookie)
|
||||
return NULL;
|
||||
|
||||
DiskSystemMap::Iterator it = fDiskSystems->FindClose(*cookie, false);
|
||||
if (it != fDiskSystems->End()) {
|
||||
KDiskSystem* diskSystem = it->Value();
|
||||
@@ -866,7 +859,7 @@ KDiskDeviceManager::NextDiskSystem(int32 *cookie)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// LoadDiskSystem
|
||||
|
||||
KDiskSystem*
|
||||
KDiskDeviceManager::LoadDiskSystem(const char* name, bool byPrettyName)
|
||||
{
|
||||
@@ -879,7 +872,7 @@ KDiskDeviceManager::LoadDiskSystem(const char *name, bool byPrettyName)
|
||||
return diskSystem;
|
||||
}
|
||||
|
||||
// LoadDiskSystem
|
||||
|
||||
KDiskSystem*
|
||||
KDiskDeviceManager::LoadDiskSystem(disk_system_id id)
|
||||
{
|
||||
@@ -892,12 +885,13 @@ KDiskDeviceManager::LoadDiskSystem(disk_system_id id)
|
||||
return diskSystem;
|
||||
}
|
||||
|
||||
// LoadNextDiskSystem
|
||||
|
||||
KDiskSystem*
|
||||
KDiskDeviceManager::LoadNextDiskSystem(int32* cookie)
|
||||
{
|
||||
if (!cookie)
|
||||
return NULL;
|
||||
|
||||
if (ManagerLocker locker = this) {
|
||||
if (KDiskSystem* diskSystem = NextDiskSystem(cookie)) {
|
||||
if (diskSystem->Load() == B_OK) {
|
||||
@@ -909,7 +903,7 @@ KDiskDeviceManager::LoadNextDiskSystem(int32 *cookie)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// InitialDeviceScan
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::InitialDeviceScan()
|
||||
{
|
||||
@@ -1035,19 +1029,20 @@ KDiskDeviceManager::RescanDiskSystems()
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _AddPartitioningSystem
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::_AddPartitioningSystem(const char* name)
|
||||
{
|
||||
if (!name)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
KDiskSystem* diskSystem = new(nothrow) KPartitioningSystem(name);
|
||||
if (!diskSystem)
|
||||
return B_NO_MEMORY;
|
||||
return _AddDiskSystem(diskSystem);
|
||||
}
|
||||
|
||||
// _AddFileSystem
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::_AddFileSystem(const char* name)
|
||||
{
|
||||
@@ -1061,7 +1056,7 @@ KDiskDeviceManager::_AddFileSystem(const char *name)
|
||||
return _AddDiskSystem(diskSystem);
|
||||
}
|
||||
|
||||
// _AddDiskSystem
|
||||
|
||||
status_t
|
||||
KDiskDeviceManager::_AddDiskSystem(KDiskSystem* diskSystem)
|
||||
{
|
||||
@@ -1080,7 +1075,7 @@ KDiskDeviceManager::_AddDiskSystem(KDiskSystem *diskSystem)
|
||||
return error;
|
||||
}
|
||||
|
||||
// _AddDevice
|
||||
|
||||
bool
|
||||
KDiskDeviceManager::_AddDevice(KDiskDevice* device)
|
||||
{
|
||||
@@ -1092,7 +1087,7 @@ KDiskDeviceManager::_AddDevice(KDiskDevice *device)
|
||||
return false;
|
||||
}
|
||||
|
||||
// _RemoveDevice
|
||||
|
||||
bool
|
||||
KDiskDeviceManager::_RemoveDevice(KDiskDevice* device)
|
||||
{
|
||||
@@ -1102,7 +1097,6 @@ KDiskDeviceManager::_RemoveDevice(KDiskDevice *device)
|
||||
|
||||
|
||||
#if 0
|
||||
// _UpdateBusyPartitions
|
||||
/*!
|
||||
The device must be write locked, the manager must be locked.
|
||||
*/
|
||||
@@ -1166,7 +1160,6 @@ KDiskDeviceManager::_UpdateBusyPartitions(KDiskDevice *device)
|
||||
#endif
|
||||
|
||||
|
||||
// _Scan
|
||||
status_t
|
||||
KDiskDeviceManager::_Scan(const char* path)
|
||||
{
|
||||
@@ -1211,6 +1204,7 @@ KDiskDeviceManager::_Scan(const char *path)
|
||||
KDiskDevice* device = new(nothrow) KDiskDevice;
|
||||
if (!device)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// init the KDiskDevice
|
||||
error = device->SetTo(path);
|
||||
// add the device
|
||||
@@ -1223,7 +1217,7 @@ KDiskDeviceManager::_Scan(const char *path)
|
||||
return error;
|
||||
}
|
||||
|
||||
// _ScanPartition
|
||||
|
||||
/*!
|
||||
The device must be write locked, the manager must be locked.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user