Implemented all Can*() and Validate*() methods. Signature changes to the methods for resizing and moving.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4021 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <DiskDeviceDefs.h>
|
#include <DiskDeviceDefs.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class BDiskDevice;
|
class BDiskDevice;
|
||||||
@@ -75,13 +76,14 @@ public:
|
|||||||
bool CanRepair(bool checkOnly, bool *whileMounted = NULL) const;
|
bool CanRepair(bool checkOnly, bool *whileMounted = NULL) const;
|
||||||
status_t Repair(bool checkOnly) const;
|
status_t Repair(bool checkOnly) const;
|
||||||
|
|
||||||
bool CanResize(bool *whileMounted = NULL) const;
|
bool CanResize(bool *canResizeContents, bool *whileMounted = NULL) const;
|
||||||
status_t ValidateResize(off_t *size) const;
|
status_t ValidateResize(off_t *size, bool resizeContents = true) const;
|
||||||
status_t Resize(off_t size);
|
status_t Resize(off_t size, bool resizeContents = true);
|
||||||
|
|
||||||
bool CanMove(bool *whileMounted = NULL) const;
|
bool CanMove(BObjectList<BPartition> *unmovableDescendants,
|
||||||
status_t ValidateMove(off_t *offset) const;
|
bool *whileMounted = NULL) const;
|
||||||
status_t Move(off_t offset);
|
status_t ValidateMove(off_t *newOffset, bool force = false) const;
|
||||||
|
status_t Move(off_t newOffset, bool force = false);
|
||||||
|
|
||||||
bool CanSetName() const;
|
bool CanSetName() const;
|
||||||
status_t ValidateSetName(char *name) const;
|
status_t ValidateSetName(char *name) const;
|
||||||
@@ -99,12 +101,13 @@ public:
|
|||||||
// returns.
|
// returns.
|
||||||
status_t SetType(const char *type);
|
status_t SetType(const char *type);
|
||||||
|
|
||||||
bool CanEditParameters(bool *whileMounted = NULL) const;
|
bool CanEditParameters() const;
|
||||||
status_t GetParameterEditor(
|
status_t GetParameterEditor(BDiskDeviceParameterEditor **editor);
|
||||||
BDiskDeviceParameterEditor **editor,
|
status_t SetParameters(const char *parameters);
|
||||||
BDiskDeviceParameterEditor **contentEditor);
|
|
||||||
status_t SetParameters(const char *parameters,
|
bool CanEditContentParameters(bool *whileMounted = NULL) const;
|
||||||
const char *contentParameters);
|
status_t GetContentParameterEditor(BDiskDeviceParameterEditor **editor);
|
||||||
|
status_t SetContentParameters(const char *parameters);
|
||||||
|
|
||||||
bool CanInitialize(const char *diskSystem) const;
|
bool CanInitialize(const char *diskSystem) const;
|
||||||
status_t GetInitializationParameterEditor(const char *system,
|
status_t GetInitializationParameterEditor(const char *system,
|
||||||
@@ -141,6 +144,7 @@ private:
|
|||||||
partition_id _ShadowID() const;
|
partition_id _ShadowID() const;
|
||||||
disk_system_id _DiskSystem() const;
|
disk_system_id _DiskSystem() const;
|
||||||
|
|
||||||
|
int32 _CountDescendants() const;
|
||||||
int32 _Level() const;
|
int32 _Level() const;
|
||||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
||||||
BPartition *_VisitEachDescendant(BDiskDeviceVisitor *visitor,
|
BPartition *_VisitEachDescendant(BDiskDeviceVisitor *visitor,
|
||||||
|
|||||||
+127
-61
@@ -406,9 +406,9 @@ BPartition::VisitEachDescendant(BDiskDeviceVisitor *visitor)
|
|||||||
bool
|
bool
|
||||||
BPartition::CanDefragment(bool *whileMounted) const
|
BPartition::CanDefragment(bool *whileMounted) const
|
||||||
{
|
{
|
||||||
return (fPartitionData && _DiskSystem() >= 0
|
return (fPartitionData && _IsShadow()
|
||||||
&& _kern_supports_defragmenting_partition(_DiskSystem(),
|
&& _kern_supports_defragmenting_partition(_ShadowID(),
|
||||||
_ShadowID(), whileMounted));
|
whileMounted));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defragment
|
// Defragment
|
||||||
@@ -423,9 +423,9 @@ BPartition::Defragment() const
|
|||||||
bool
|
bool
|
||||||
BPartition::CanRepair(bool checkOnly, bool *whileMounted) const
|
BPartition::CanRepair(bool checkOnly, bool *whileMounted) const
|
||||||
{
|
{
|
||||||
return (fPartitionData && _DiskSystem() >= 0
|
return (fPartitionData && _IsShadow()
|
||||||
&& _kern_supports_repairing_partition(_DiskSystem(), _ShadowID(),
|
&& _kern_supports_repairing_partition(_ShadowID(), checkOnly,
|
||||||
checkOnly, whileMounted));
|
whileMounted));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repair
|
// Repair
|
||||||
@@ -438,31 +438,25 @@ BPartition::Repair(bool checkOnly) const
|
|||||||
|
|
||||||
// CanResize
|
// CanResize
|
||||||
bool
|
bool
|
||||||
BPartition::CanResize(bool *whileMounted) const
|
BPartition::CanResize(bool *canResizeContents, bool *whileMounted) const
|
||||||
{
|
{
|
||||||
if (!fPartitionData || IsDevice() || !Parent() || _DiskSystem() < 0
|
return (fPartitionData && !IsDevice() && Parent() && _IsShadow()
|
||||||
|| Parent()->_DiskSystem() < 0) {
|
&& _kern_supports_resizing_partition(_ShadowID(),
|
||||||
return false;
|
canResizeContents, whileMounted));
|
||||||
}
|
|
||||||
if (!_kern_supports_resizing_partition(_DiskSystem(), _ShadowID(),
|
|
||||||
whileMounted)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _kern_supports_resizing_child_partition(Parent()->_DiskSystem(),
|
|
||||||
_ShadowID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateResize
|
// ValidateResize
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateResize(off_t *size) const
|
BPartition::ValidateResize(off_t *size, bool resizeContents) const
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow() || !size)
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
|
return _kern_validate_resize_partition(_ShadowID(), size, resizeContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
status_t
|
status_t
|
||||||
BPartition::Resize(off_t size)
|
BPartition::Resize(off_t size, bool resizeContents)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -470,23 +464,56 @@ BPartition::Resize(off_t size)
|
|||||||
|
|
||||||
// CanMove
|
// CanMove
|
||||||
bool
|
bool
|
||||||
BPartition::CanMove(bool *whileMounted) const
|
BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
||||||
|
bool *whileMounted) const
|
||||||
{
|
{
|
||||||
// not implemented
|
// check parameters
|
||||||
return false;
|
if (!unmovableDescendants || !fPartitionData || IsDevice() || !Parent()
|
||||||
|
|| !_IsShadow()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// count descendants and allocate a partition_id array large enough
|
||||||
|
int32 descendantCount = _CountDescendants();
|
||||||
|
partition_id *descendants = NULL;
|
||||||
|
if (descendantCount > 0) {
|
||||||
|
descendants = new(nothrow) partition_id[descendantCount];
|
||||||
|
if (!descendants)
|
||||||
|
return false;
|
||||||
|
for (int32 i = 0; i < descendantCount; i++)
|
||||||
|
descendants[i] = -1;
|
||||||
|
}
|
||||||
|
// get the info
|
||||||
|
bool result = _kern_supports_moving_partition(_ShadowID(), descendants,
|
||||||
|
descendantCount, whileMounted);
|
||||||
|
if (result) {
|
||||||
|
// find BPartition objects for returned IDs
|
||||||
|
for (int32 i = 0; i < descendantCount && descendants[i] != -1; i++) {
|
||||||
|
BPartition *descendant = FindDescendant(descendants[i]);
|
||||||
|
if (!descendant || !unmovableDescendants->AddItem(descendant)) {
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// cleanup and return
|
||||||
|
delete[] descendants;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateMove
|
// ValidateMove
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateMove(off_t *offset) const
|
BPartition::ValidateMove(off_t *newOffset, bool force) const
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow()
|
||||||
return B_ERROR;
|
|| !newOffset) {
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
return _kern_validate_move_partition(_ShadowID(), newOffset, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
status_t
|
status_t
|
||||||
BPartition::Move(off_t offset)
|
BPartition::Move(off_t newOffset, bool force)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -496,17 +523,17 @@ BPartition::Move(off_t offset)
|
|||||||
bool
|
bool
|
||||||
BPartition::CanSetName() const
|
BPartition::CanSetName() const
|
||||||
{
|
{
|
||||||
return (fPartitionData && Parent() && Parent()->_DiskSystem() >= 0
|
return (fPartitionData && Parent() && _IsShadow()
|
||||||
&& _kern_supports_setting_partition_name(Parent()->_DiskSystem(),
|
&& _kern_supports_setting_partition_name(_ShadowID()));
|
||||||
_ShadowID()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateSetName
|
// ValidateSetName
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateSetName(char *name) const
|
BPartition::ValidateSetName(char *name) const
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow())
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
|
return _kern_validate_set_partition_name(_ShadowID(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetName
|
// SetName
|
||||||
@@ -521,17 +548,18 @@ BPartition::SetName(const char *name)
|
|||||||
bool
|
bool
|
||||||
BPartition::CanSetContentName(bool *whileMounted) const
|
BPartition::CanSetContentName(bool *whileMounted) const
|
||||||
{
|
{
|
||||||
return (fPartitionData && _DiskSystem() >= 0
|
return (fPartitionData && _IsShadow()
|
||||||
&& _kern_supports_setting_partition_content_name(_DiskSystem(),
|
&& _kern_supports_setting_partition_content_name(_ShadowID(),
|
||||||
_ShadowID(), whileMounted));
|
whileMounted));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateSetContentName
|
// ValidateSetContentName
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateSetContentName(char *name) const
|
BPartition::ValidateSetContentName(char *name) const
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || !_IsShadow())
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
|
return _kern_validate_set_partition_content_name(_ShadowID(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetContentName
|
// SetContentName
|
||||||
@@ -546,17 +574,17 @@ BPartition::SetContentName(const char *name)
|
|||||||
bool
|
bool
|
||||||
BPartition::CanSetType() const
|
BPartition::CanSetType() const
|
||||||
{
|
{
|
||||||
return (fPartitionData && Parent() && Parent()->_DiskSystem() >= 0
|
return (fPartitionData && Parent() && _IsShadow()
|
||||||
&& _kern_supports_setting_partition_type(Parent()->_DiskSystem(),
|
&& _kern_supports_setting_partition_type(_ShadowID()));
|
||||||
_ShadowID()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateSetType
|
// ValidateSetType
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateSetType(const char *type) const
|
BPartition::ValidateSetType(const char *type) const
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow() || !type)
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
|
return _kern_validate_set_partition_type(_ShadowID(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetType
|
// SetType
|
||||||
@@ -569,16 +597,15 @@ BPartition::SetType(const char *type)
|
|||||||
|
|
||||||
// CanEditParameters
|
// CanEditParameters
|
||||||
bool
|
bool
|
||||||
BPartition::CanEditParameters(bool *whileMounted) const
|
BPartition::CanEditParameters() const
|
||||||
{
|
{
|
||||||
// not implemented
|
return (fPartitionData && Parent() && _IsShadow()
|
||||||
return false;
|
&& _kern_supports_setting_partition_parameters(_ShadowID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetParameterEditor
|
// GetParameterEditor
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetParameterEditor(BDiskDeviceParameterEditor **editor,
|
BPartition::GetParameterEditor(BDiskDeviceParameterEditor **editor)
|
||||||
BDiskDeviceParameterEditor **contentEditor)
|
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -586,8 +613,32 @@ BPartition::GetParameterEditor(BDiskDeviceParameterEditor **editor,
|
|||||||
|
|
||||||
// SetParameters
|
// SetParameters
|
||||||
status_t
|
status_t
|
||||||
BPartition::SetParameters(const char *parameters,
|
BPartition::SetParameters(const char *parameters)
|
||||||
const char *contentParameters)
|
{
|
||||||
|
// not implemented
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanEditContentParameters
|
||||||
|
bool
|
||||||
|
BPartition::CanEditContentParameters(bool *whileMounted) const
|
||||||
|
{
|
||||||
|
return (fPartitionData && _IsShadow()
|
||||||
|
&& _kern_supports_setting_partition_content_parameters(
|
||||||
|
_ShadowID(), whileMounted));
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetContentParameterEditor
|
||||||
|
status_t
|
||||||
|
BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor **editor)
|
||||||
|
{
|
||||||
|
// not implemented
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetParameters
|
||||||
|
status_t
|
||||||
|
BPartition::SetContentParameters(const char *parameters)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -597,8 +648,8 @@ BPartition::SetParameters(const char *parameters,
|
|||||||
bool
|
bool
|
||||||
BPartition::CanInitialize(const char *diskSystem) const
|
BPartition::CanInitialize(const char *diskSystem) const
|
||||||
{
|
{
|
||||||
// not implemented
|
return (fPartitionData && diskSystem && _IsShadow()
|
||||||
return false;
|
&& _kern_supports_initializing_partition(_ShadowID(), diskSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetInitializationParameterEditor
|
// GetInitializationParameterEditor
|
||||||
@@ -615,8 +666,10 @@ status_t
|
|||||||
BPartition::ValidateInitialize(const char *diskSystem, char *name,
|
BPartition::ValidateInitialize(const char *diskSystem, char *name,
|
||||||
const char *parameters)
|
const char *parameters)
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || !_IsShadow() || !diskSystem)
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
|
return _kern_validate_initialize_partition(_ShadowID(), diskSystem, name,
|
||||||
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
@@ -632,8 +685,8 @@ BPartition::Initialize(const char *diskSystem, const char *name,
|
|||||||
bool
|
bool
|
||||||
BPartition::CanCreateChild() const
|
BPartition::CanCreateChild() const
|
||||||
{
|
{
|
||||||
// not implemented
|
return (fPartitionData && _IsShadow()
|
||||||
return false;
|
&& _kern_supports_creating_child_partition(_ShadowID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChildCreationParameterEditor
|
// GetChildCreationParameterEditor
|
||||||
@@ -647,11 +700,13 @@ BPartition::GetChildCreationParameterEditor(const char *system,
|
|||||||
|
|
||||||
// ValidateCreateChild
|
// ValidateCreateChild
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateCreateChild(off_t *start, off_t *size, const char *type,
|
BPartition::ValidateCreateChild(off_t *offset, off_t *size, const char *type,
|
||||||
const char *parameters) const
|
const char *parameters) const
|
||||||
{
|
{
|
||||||
// not implemented
|
if (!fPartitionData || !_IsShadow() || !offset || !size || !type)
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
|
return _kern_validate_create_child_partition(_ShadowID(), offset, size,
|
||||||
|
type, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateChild
|
// CreateChild
|
||||||
@@ -667,8 +722,9 @@ BPartition::CreateChild(off_t start, off_t size, const char *type,
|
|||||||
bool
|
bool
|
||||||
BPartition::CanDeleteChild(int32 index) const
|
BPartition::CanDeleteChild(int32 index) const
|
||||||
{
|
{
|
||||||
// not implemented
|
BPartition *child = ChildAt(index);
|
||||||
return false;
|
return (child && child->_IsShadow()
|
||||||
|
&& _kern_supports_deleting_child_partition(child->_ShadowID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteChild
|
// DeleteChild
|
||||||
@@ -762,6 +818,16 @@ BPartition::_DiskSystem() const
|
|||||||
return (fPartitionData ? fPartitionData->disk_system : -1);
|
return (fPartitionData ? fPartitionData->disk_system : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _CountDescendants
|
||||||
|
int32
|
||||||
|
BPartition::_CountDescendants() const
|
||||||
|
{
|
||||||
|
int32 count = 1;
|
||||||
|
for (int32 i = 0; BPartition *child = ChildAt(i); i++)
|
||||||
|
count += child->_CountDescendants();
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
// _Level
|
// _Level
|
||||||
int32
|
int32
|
||||||
BPartition::_Level() const
|
BPartition::_Level() const
|
||||||
|
|||||||
Reference in New Issue
Block a user