* 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:
@@ -9,9 +9,12 @@
|
|||||||
#include <DiskDeviceDefs.h>
|
#include <DiskDeviceDefs.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class BPartition;
|
class BPartition;
|
||||||
|
class BString;
|
||||||
struct user_disk_system_info;
|
struct user_disk_system_info;
|
||||||
|
|
||||||
|
|
||||||
class BDiskSystem {
|
class BDiskSystem {
|
||||||
public:
|
public:
|
||||||
BDiskSystem();
|
BDiskSystem();
|
||||||
@@ -40,21 +43,17 @@ public:
|
|||||||
bool SupportsDeletingChild() const;
|
bool SupportsDeletingChild() const;
|
||||||
bool SupportsInitializing() const;
|
bool SupportsInitializing() const;
|
||||||
|
|
||||||
status_t GetNextSupportedType(BPartition *partition, int32 *cookie,
|
status_t GetTypeForContentType(const char *contentType,
|
||||||
char *type) const;
|
BString* type) const;
|
||||||
// Returns all types the disk system supports for children of the
|
|
||||||
// supplied partition.
|
|
||||||
status_t GetTypeForContentType(const char *contentType, char *type) const;
|
|
||||||
|
|
||||||
bool IsPartitioningSystem() const;
|
bool IsPartitioningSystem() const;
|
||||||
bool IsFileSystem() const;
|
bool IsFileSystem() const;
|
||||||
bool IsSubSystemFor(BPartition *parent) const;
|
|
||||||
|
|
||||||
BDiskSystem& operator=(const BDiskSystem& other);
|
BDiskSystem& operator=(const BDiskSystem& other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _SetTo(disk_system_id id);
|
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();
|
void _Unset();
|
||||||
|
|
||||||
friend class BDiskDeviceRoster;
|
friend class BDiskDeviceRoster;
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ public:
|
|||||||
const char* name, const char* parameters,
|
const char* name, const char* parameters,
|
||||||
BPartitionHandle** handle);
|
BPartitionHandle** handle);
|
||||||
|
|
||||||
|
virtual status_t GetTypeForContentType(const char* contentType,
|
||||||
|
BString* type);
|
||||||
|
virtual bool IsSubSystemFor(const BMutablePartition* child);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fName;
|
BString fName;
|
||||||
uint32 fFlags;
|
uint32 fFlags;
|
||||||
@@ -62,14 +66,11 @@ public:
|
|||||||
virtual bool SupportsInitializingChild(
|
virtual bool SupportsInitializingChild(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
const char* diskSystem);
|
const char* diskSystem);
|
||||||
virtual bool IsSubSystemFor(const BMutablePartition* child);
|
|
||||||
|
|
||||||
virtual status_t GetNextSupportedType(
|
virtual status_t GetNextSupportedType(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
int32* cookie, BString* type);
|
int32* cookie, BString* type);
|
||||||
// child can be NULL
|
// child can be NULL
|
||||||
virtual status_t GetTypeForContentType(const char* contentType,
|
|
||||||
BString* type);
|
|
||||||
|
|
||||||
virtual status_t GetPartitioningInfo(BPartitioningInfo* info);
|
virtual status_t GetPartitioningInfo(BPartitioningInfo* info);
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,18 @@ public:
|
|||||||
BDiskDeviceParameterEditor** editor);
|
BDiskDeviceParameterEditor** editor);
|
||||||
status_t SetContentParameters(const char* parameters);
|
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;
|
bool CanInitialize(const char* diskSystem) const;
|
||||||
status_t GetInitializationParameterEditor(
|
status_t GetInitializationParameterEditor(
|
||||||
const char* system,
|
const char* system,
|
||||||
|
|||||||
@@ -4,10 +4,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <DiskSystem.h>
|
#include <DiskSystem.h>
|
||||||
|
|
||||||
|
#include <DiskSystemAddOn.h>
|
||||||
#include <Partition.h>
|
#include <Partition.h>
|
||||||
|
|
||||||
#include <syscalls.h>
|
|
||||||
#include <disk_device_manager/ddm_userland_interface.h>
|
#include <disk_device_manager/ddm_userland_interface.h>
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
|
#include "DiskSystemAddOnManager.h"
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// 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
|
// GetTypeForContentType
|
||||||
status_t
|
status_t
|
||||||
BDiskSystem::GetTypeForContentType(const char* contentType, char* type) const
|
BDiskSystem::GetTypeForContentType(const char* contentType, BString* type) const
|
||||||
{
|
{
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return InitCheck();
|
return InitCheck();
|
||||||
|
|
||||||
if (!contentType || !type || !IsPartitioningSystem())
|
if (!contentType || !type || !IsPartitioningSystem())
|
||||||
return B_BAD_VALUE;
|
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&
|
||||||
BDiskSystem::operator=(const BDiskSystem& other)
|
BDiskSystem::operator=(const BDiskSystem& other)
|
||||||
@@ -371,7 +355,7 @@ BDiskSystem::_SetTo(disk_system_id id)
|
|||||||
|
|
||||||
// _SetTo
|
// _SetTo
|
||||||
status_t
|
status_t
|
||||||
BDiskSystem::_SetTo(user_disk_system_info* info)
|
BDiskSystem::_SetTo(const user_disk_system_info* info)
|
||||||
{
|
{
|
||||||
_Unset();
|
_Unset();
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// #pragma mark - BPartitionHandle
|
||||||
|
|
||||||
|
|
||||||
@@ -126,14 +142,6 @@ BPartitionHandle::SupportsInitializingChild(const BMutablePartition* child,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IsSubSystemFor
|
|
||||||
bool
|
|
||||||
BPartitionHandle::IsSubSystemFor(const BMutablePartition* child)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// GetNextSupportedType
|
// GetNextSupportedType
|
||||||
status_t
|
status_t
|
||||||
BPartitionHandle::GetNextSupportedType(const BMutablePartition* child,
|
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
|
// GetPartitioningInfo
|
||||||
status_t
|
status_t
|
||||||
BPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info)
|
BPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info)
|
||||||
|
|||||||
@@ -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
|
// CanInitialize
|
||||||
bool
|
bool
|
||||||
BPartition::CanInitialize(const char* diskSystem) const
|
BPartition::CanInitialize(const char* diskSystem) const
|
||||||
|
|||||||
@@ -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
|
// CanInitialize
|
||||||
bool
|
bool
|
||||||
BPartition::Delegate::CanInitialize(const char* diskSystem) const
|
BPartition::Delegate::CanInitialize(const char* diskSystem) const
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ public:
|
|||||||
status_t SetParameters(Delegate* child,
|
status_t SetParameters(Delegate* child,
|
||||||
const char* parameters);
|
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;
|
bool CanInitialize(const char* diskSystem) const;
|
||||||
status_t GetInitializationParameterEditor(
|
status_t GetInitializationParameterEditor(
|
||||||
const char* system,
|
const char* system,
|
||||||
|
|||||||
Reference in New Issue
Block a user