Implemented the BDiskSystem::Supports*() methods. Added required private helper methods to BPartition.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3989 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-07-15 21:44:23 +00:00
parent 1863de6785
commit 910d993921
4 changed files with 108 additions and 37 deletions

View File

@ -35,19 +35,26 @@ public:
bool *whileMounted) const;
bool SupportsSettingType(BPartition *partition) const;
bool SupportsCreatingChild(BPartition *partition) const;
bool SupportsParentSystem(BPartition *child, const char *system) const;
bool SupportsDeletingChild(BPartition *child) const;
bool SupportsInitializing(BPartition *partition) const;
bool SupportsInitializingChild(BPartition *child,
const char *diskSystem) const;
bool SupportsParentSystem(BPartition *child) const;
bool SupportsParentSystem(const char *system) const;
// True in most cases. NULL == raw device.
bool SupportsChildSystem(BPartition *child, const char *system) const;
bool SupportsChildSystem(const char *system) const;
// False for most file systems, true for most partitioning
// systems.
status_t ValidateResize(BPartition *partition, off_t *size) const;
status_t ValidateMove(BPartition *partition, off_t *start) const;
status_t ValidateResizeChild(BPartition *partition, off_t *size) const;
status_t ValidateMove(BPartition *partition, off_t *start) const;
status_t ValidateMoveChild(BPartition *partition, off_t *start) const;
status_t ValidateSetName(BPartition *partition, char *name) const;
status_t ValidateSetContentName(BPartition *partition, char *name) const;
status_t ValidateSetType(BPartition *partition, char *type) const;
status_t ValidateSetType(BPartition *partition, const char *type) const;
status_t ValidateCreateChild(BPartition *partition, off_t *start,
off_t *size, const char *type,
const char *parameters) const;

View File

@ -134,6 +134,8 @@ private:
void _Unset();
bool _IsShadow() const;
partition_id _ShadowID() const;
disk_system_id _DiskSystem() const;
int32 _Level() const;
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
@ -141,6 +143,7 @@ private:
int32 level = -1);
friend class BDiskDevice;
friend class BDiskSystem;
BDiskDevice *fDevice;
BPartition *fParent;

View File

@ -3,8 +3,9 @@
// by the OpenBeOS license.
//---------------------------------------------------------------------
#include <DiskSystem.h>
#include <ddm_userland_interface.h>
#include <DiskSystem.h>
#include <Partition.h>
// constructor
BDiskSystem::BDiskSystem()
@ -46,8 +47,11 @@ bool
BDiskSystem::SupportsDefragmenting(BPartition *partition,
bool *whileMounted) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsFileSystem()
&& partition && partition->_IsShadow()
&& partition->_DiskSystem() == fID
&& _kern_supports_defragmenting_partition(fID,
partition->_ShadowID(), whileMounted));
}
// SupportsRepairing
@ -55,48 +59,65 @@ bool
BDiskSystem::SupportsRepairing(BPartition *partition, bool checkOnly,
bool *whileMounted) const
{
// not implemented
return false;
return (InitCheck() == B_OK
&& partition && partition->_IsShadow()
&& partition->_DiskSystem() == fID
&& _kern_supports_repairing_partition(fID, partition->_ShadowID(),
checkOnly, whileMounted));
}
// SupportsResizing
bool
BDiskSystem::SupportsResizing(BPartition *partition, bool *whileMounted) const
{
// not implemented
return false;
return (InitCheck() == B_OK
&& partition && partition->_IsShadow()
&& partition->_DiskSystem() == fID
&& _kern_supports_resizing_partition(fID, partition->_ShadowID(),
whileMounted));
}
// SupportsResizingChild
bool
BDiskSystem::SupportsResizingChild(BPartition *child) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsPartitioningSystem()
&& child && child->_IsShadow() && child->Parent()
&& child->Parent()->_DiskSystem() == fID
&& _kern_supports_resizing_child_partition(fID,
child->_ShadowID()));
}
// SupportsMoving
bool
BDiskSystem::SupportsMoving(BPartition *partition, bool *whileMounted) const
{
// not implemented
return false;
return (InitCheck() == B_OK
&& partition && partition->_IsShadow()
&& partition->_DiskSystem() == fID
&& _kern_supports_moving_partition(fID, partition->_ShadowID(),
whileMounted));
}
// SupportsMovingChild
bool
BDiskSystem::SupportsMovingChild(BPartition *child) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsPartitioningSystem()
&& child && child->_IsShadow() && child->Parent()
&& child->Parent()->_DiskSystem() == fID
&& _kern_supports_moving_child_partition(fID, child->_ShadowID()));
}
// SupportsSettingName
bool
BDiskSystem::SupportsSettingName(BPartition *partition) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsPartitioningSystem()
&& partition && partition->_IsShadow() && partition->Parent()
&& partition->Parent()->_DiskSystem() == fID
&& _kern_supports_setting_partition_name(fID,
partition->_ShadowID()));
}
// SupportsSettingContentName
@ -104,40 +125,66 @@ bool
BDiskSystem::SupportsSettingContentName(BPartition *partition,
bool *whileMounted) const
{
// not implemented
return false;
return (InitCheck() == B_OK
&& partition && partition->_IsShadow()
&& partition->_DiskSystem() == fID
&& _kern_supports_setting_partition_content_name(fID,
partition->_ShadowID(), whileMounted));
}
// SupportsSettingType
bool
BDiskSystem::SupportsSettingType(BPartition *partition) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsPartitioningSystem()
&& partition && partition->_IsShadow() && partition->Parent()
&& partition->Parent()->_DiskSystem() == fID
&& _kern_supports_setting_partition_type(fID,
partition->_ShadowID()));
}
// SupportsCreatingChild
bool
BDiskSystem::SupportsCreatingChild(BPartition *partition) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsPartitioningSystem()
&& partition && partition->_IsShadow()
&& partition->_DiskSystem() == fID
&& _kern_supports_creating_child_partition(fID,
partition->_ShadowID()));
}
// SupportsParentSystem
// SupportsDeletingChild
bool
BDiskSystem::SupportsParentSystem(BPartition *child, const char *system) const
BDiskSystem::SupportsDeletingChild(BPartition *child) const
{
// not implemented
return false;
return (InitCheck() == B_OK && IsPartitioningSystem()
&& child && child->_IsShadow() && child->Parent()
&& child->Parent()->_DiskSystem() == fID
&& _kern_supports_deleting_child_partition(fID,
child->_ShadowID()));
}
// SupportsChildSystem
// SupportsInitializing
bool
BDiskSystem::SupportsChildSystem(BPartition *child, const char *system) const
BDiskSystem::SupportsInitializing(BPartition *partition) const
{
// not implemented
return false;
return (InitCheck() == B_OK
&& partition && partition->_IsShadow()
&& _kern_supports_initializing_partition(fID,
partition->_ShadowID()));
}
// SupportsInitializingChild
bool
BDiskSystem::SupportsInitializingChild(BPartition *child,
const char *diskSystem) const
{
return (InitCheck() == B_OK && IsPartitioningSystem() && diskSystem
&& child && child->_IsShadow() && child->Parent()
&& child->Parent()->_DiskSystem() == fID
&& _kern_supports_initializing_child_partition(fID,
child->_ShadowID(), diskSystem));
}
// ValidateResize
@ -148,17 +195,17 @@ BDiskSystem::ValidateResize(BPartition *partition, off_t *size) const
return B_ERROR;
}
// ValidateMove
// ValidateResizeChild
status_t
BDiskSystem::ValidateMove(BPartition *partition, off_t *start) const
BDiskSystem::ValidateResizeChild(BPartition *partition, off_t *size) const
{
// not implemented
return B_ERROR;
}
// ValidateResizeChild
// ValidateMove
status_t
BDiskSystem::ValidateResizeChild(BPartition *partition, off_t *size) const
BDiskSystem::ValidateMove(BPartition *partition, off_t *start) const
{
// not implemented
return B_ERROR;
@ -190,7 +237,7 @@ BDiskSystem::ValidateSetContentName(BPartition *partition, char *name) const
// ValidateSetType
status_t
BDiskSystem::ValidateSetType(BPartition *partition, char *type) const
BDiskSystem::ValidateSetType(BPartition *partition, const char *type) const
{
// not implemented
return B_ERROR;

View File

@ -451,6 +451,20 @@ BPartition::_IsShadow() const
return (fPartitionData && fPartitionData->shadow_id >= 0);
}
// _ShadowID
partition_id
BPartition::_ShadowID() const
{
return (fPartitionData ? fPartitionData->shadow_id : -1);
}
// _DiskSystem
disk_system_id
BPartition::_DiskSystem() const
{
return (fPartitionData ? fPartitionData->disk_system : -1);
}
// _Level
int32
BPartition::_Level() const