* Moved GetNextSupportedType() and IsSubSystemFor() from

BDiskSystem to BPartition and reimplemented them using the userland
  add-on backend instead of syscalls. As a side effect this solves the
  TODO I recently added in GetNextSupportedType().
* Reimplemented BDiskSystem::GetTypeForContentType() using the userland
  add-on backend instead of a syscall.
* Moved GetTypeForContentType() and IsSubSystemFor() from
  BPartitionHandle to BDiskSystemAddOn. They were misplaced.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22592 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-10-17 01:01:49 +00:00
parent d712d042ea
commit fe6bd3b5b7
8 changed files with 132 additions and 63 deletions

View File

@ -9,9 +9,12 @@
#include <DiskDeviceDefs.h>
#include <String.h>
class BPartition;
class BString;
struct user_disk_system_info;
class BDiskSystem {
public:
BDiskSystem();
@ -40,21 +43,17 @@ public:
bool SupportsDeletingChild() const;
bool SupportsInitializing() const;
status_t GetNextSupportedType(BPartition *partition, int32 *cookie,
char *type) const;
// Returns all types the disk system supports for children of the
// supplied partition.
status_t GetTypeForContentType(const char *contentType, char *type) const;
status_t GetTypeForContentType(const char *contentType,
BString* type) const;
bool IsPartitioningSystem() const;
bool IsFileSystem() const;
bool IsSubSystemFor(BPartition *parent) const;
BDiskSystem& operator=(const BDiskSystem& other);
private:
status_t _SetTo(disk_system_id id);
status_t _SetTo(user_disk_system_info *info);
status_t _SetTo(const user_disk_system_info *info);
void _Unset();
friend class BDiskDeviceRoster;

View File

@ -41,6 +41,10 @@ public:
const char* name, const char* parameters,
BPartitionHandle** handle);
virtual status_t GetTypeForContentType(const char* contentType,
BString* type);
virtual bool IsSubSystemFor(const BMutablePartition* child);
private:
BString fName;
uint32 fFlags;
@ -62,14 +66,11 @@ public:
virtual bool SupportsInitializingChild(
const BMutablePartition* child,
const char* diskSystem);
virtual bool IsSubSystemFor(const BMutablePartition* child);
virtual status_t GetNextSupportedType(
const BMutablePartition* child,
int32* cookie, BString* type);
// child can be NULL
virtual status_t GetTypeForContentType(const char* contentType,
BString* type);
virtual status_t GetPartitioningInfo(BPartitioningInfo* info);

View File

@ -128,6 +128,18 @@ public:
BDiskDeviceParameterEditor** editor);
status_t SetContentParameters(const char* parameters);
status_t GetNextSupportedType(int32 *cookie,
BString* type) const;
// Returns all partition types for this
// partition supported by the parent disk
// system.
status_t GetNextSupportedChildType(int32 *cookie,
BString* type) const;
// Returns all partition types for a child
// of this partition supported by its disk
// system.
bool IsSubSystem(const char* diskSystem) const;
bool CanInitialize(const char* diskSystem) const;
status_t GetInitializationParameterEditor(
const char* system,

View File

@ -4,10 +4,14 @@
*/
#include <DiskSystem.h>
#include <DiskSystemAddOn.h>
#include <Partition.h>
#include <syscalls.h>
#include <disk_device_manager/ddm_userland_interface.h>
#include <syscalls.h>
#include "DiskSystemAddOnManager.h"
// constructor
@ -277,37 +281,28 @@ BDiskSystem::SupportsInitializing() const
}
// GetNextSupportedType
status_t
BDiskSystem::GetNextSupportedType(BPartition* partition, int32* cookie,
char* type) const
{
// TODO: We probably need a second method for and modify the partitioning
// system module hook a little. This method takes the parent partition of
// a partition to be created for which we want to get supported types. It
// should also be possible to invoke it for the partition whose type to change
// though.
if (InitCheck() != B_OK)
return InitCheck();
if (!cookie || !type || !partition || !partition->_IsShadow()
|| partition->_DiskSystem() != fID || !IsPartitioningSystem()) {
return B_BAD_VALUE;
}
return _kern_get_next_supported_partition_type(partition->_ShadowID(),
partition->_ChangeCounter(), cookie, type);
}
// GetTypeForContentType
status_t
BDiskSystem::GetTypeForContentType(const char* contentType, char* type) const
BDiskSystem::GetTypeForContentType(const char* contentType, BString* type) const
{
if (InitCheck() != B_OK)
return InitCheck();
if (!contentType || !type || !IsPartitioningSystem())
return B_BAD_VALUE;
return _kern_get_partition_type_for_content_type(fID, contentType, type);
// get the disk system add-on
DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default();
BDiskSystemAddOn* addOn = manager->GetAddOn(fName.String());
if (!addOn)
return B_ENTRY_NOT_FOUND;
status_t result = addOn->GetTypeForContentType(contentType, type);
// put the add-on
manager->PutAddOn(addOn);
return result;
}
@ -327,17 +322,6 @@ BDiskSystem::IsFileSystem() const
}
// IsSubSystemFor
bool
BDiskSystem::IsSubSystemFor(BPartition* parent) const
{
return (InitCheck() == B_OK
&& parent && parent->_IsShadow()
&& _kern_is_sub_disk_system_for(fID, parent->_ShadowID(),
parent->_ChangeCounter()));
}
// =
BDiskSystem&
BDiskSystem::operator=(const BDiskSystem& other)
@ -371,7 +355,7 @@ BDiskSystem::_SetTo(disk_system_id id)
// _SetTo
status_t
BDiskSystem::_SetTo(user_disk_system_info* info)
BDiskSystem::_SetTo(const user_disk_system_info* info)
{
_Unset();

View File

@ -76,6 +76,22 @@ BDiskSystemAddOn::Initialize(BMutablePartition* partition, const char* name,
}
// GetTypeForContentType
status_t
BDiskSystemAddOn::GetTypeForContentType(const char* contentType, BString* type)
{
return B_NOT_SUPPORTED;
}
// IsSubSystemFor
bool
BDiskSystemAddOn::IsSubSystemFor(const BMutablePartition* child)
{
return false;
}
// #pragma mark - BPartitionHandle
@ -126,14 +142,6 @@ BPartitionHandle::SupportsInitializingChild(const BMutablePartition* child,
}
// IsSubSystemFor
bool
BPartitionHandle::IsSubSystemFor(const BMutablePartition* child)
{
return false;
}
// GetNextSupportedType
status_t
BPartitionHandle::GetNextSupportedType(const BMutablePartition* child,
@ -143,14 +151,6 @@ BPartitionHandle::GetNextSupportedType(const BMutablePartition* child,
}
// GetTypeForContentType
status_t
BPartitionHandle::GetTypeForContentType(const char* contentType, BString* type)
{
return B_NOT_SUPPORTED;
}
// GetPartitioningInfo
status_t
BPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info)

View File

@ -1059,6 +1059,42 @@ BPartition::SetContentParameters(const char* parameters)
}
// GetNextSupportedType
status_t
BPartition::GetNextSupportedType(int32 *cookie, BString* type) const
{
BPartition* parent = Parent();
if (!parent || !fDelegate)
return false;
return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie,
type);
}
// GetNextSupportedChildType
status_t
BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const
{
if (!fDelegate)
return B_BAD_VALUE;
return fDelegate->GetNextSupportedChildType(NULL, cookie, type);
}
// IsSubSystem
bool
BPartition::BPartition::IsSubSystem(const char* diskSystem) const
{
BPartition* parent = Parent();
if (!parent || !fDelegate)
return false;
return parent->fDelegate->IsSubSystem(fDelegate, diskSystem);
}
// CanInitialize
bool
BPartition::CanInitialize(const char* diskSystem) const

View File

@ -353,6 +353,38 @@ BPartition::Delegate::SetParameters(Delegate* child, const char* parameters)
}
// GetNextSupportedChildType
status_t
BPartition::Delegate::GetNextSupportedChildType(Delegate* child, int32 *cookie,
BString* type) const
{
if (!fPartitionHandle)
return B_NO_INIT;
return fPartitionHandle->GetNextSupportedType(
child ? &child->fMutablePartition : NULL, cookie, type);
}
// IsSubSystem
bool
BPartition::Delegate::IsSubSystem(Delegate* child, const char* diskSystem) const
{
// get the disk system add-on
DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default();
BDiskSystemAddOn* addOn = manager->GetAddOn(diskSystem);
if (!addOn)
return false;
bool result = addOn->IsSubSystemFor(&child->fMutablePartition);
// put the add-on
manager->PutAddOn(addOn);
return result;
}
// CanInitialize
bool
BPartition::Delegate::CanInitialize(const char* diskSystem) const

View File

@ -72,6 +72,11 @@ public:
status_t SetParameters(Delegate* child,
const char* parameters);
status_t GetNextSupportedChildType(Delegate* child,
int32 *cookie, BString* type) const;
bool IsSubSystem(Delegate* child,
const char* diskSystem) const;
bool CanInitialize(const char* diskSystem) const;
status_t GetInitializationParameterEditor(
const char* system,