* Initialization of BPartition::Delegate is now two-phased. The first phase
builds the object hierarchy, the second will (in case of MutableDelegate) let the disk systems do their initialization. This way the disk systems already find a fully functional object hierarchy they can work with. * Child creation also takes a partition name as a parameter, now. * Implemented BMutablePartition child creation/deletion. * The BDiskSystemAddOn/BPartitionHandle::Validate*() methods return a status_t instead of a bool, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22540 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -34,7 +34,7 @@ public:
|
|||||||
virtual status_t GetInitializationParameterEditor(
|
virtual status_t GetInitializationParameterEditor(
|
||||||
const BMutablePartition* partition,
|
const BMutablePartition* partition,
|
||||||
BDiskDeviceParameterEditor** editor);
|
BDiskDeviceParameterEditor** editor);
|
||||||
virtual bool ValidateInitialize(
|
virtual status_t ValidateInitialize(
|
||||||
const BMutablePartition* partition,
|
const BMutablePartition* partition,
|
||||||
BString* name, const char* parameters);
|
BString* name, const char* parameters);
|
||||||
virtual status_t Initialize(BMutablePartition* partition,
|
virtual status_t Initialize(BMutablePartition* partition,
|
||||||
@@ -77,30 +77,30 @@ public:
|
|||||||
virtual status_t Defragment();
|
virtual status_t Defragment();
|
||||||
virtual status_t Repair(bool checkOnly);
|
virtual status_t Repair(bool checkOnly);
|
||||||
|
|
||||||
virtual bool ValidateResize(off_t* size);
|
virtual status_t ValidateResize(off_t* size);
|
||||||
virtual bool ValidateResizeChild(
|
virtual status_t ValidateResizeChild(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
off_t* size);
|
off_t* size);
|
||||||
virtual status_t Resize(off_t size);
|
virtual status_t Resize(off_t size);
|
||||||
virtual status_t ResizeChild(BMutablePartition* child,
|
virtual status_t ResizeChild(BMutablePartition* child,
|
||||||
off_t size);
|
off_t size);
|
||||||
|
|
||||||
virtual bool ValidateMove(off_t* offset);
|
virtual status_t ValidateMove(off_t* offset);
|
||||||
virtual bool ValidateMoveChild(
|
virtual status_t ValidateMoveChild(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
off_t* offset);
|
off_t* offset);
|
||||||
virtual status_t Move(off_t offset);
|
virtual status_t Move(off_t offset);
|
||||||
virtual status_t MoveChild(BMutablePartition* child,
|
virtual status_t MoveChild(BMutablePartition* child,
|
||||||
off_t offset);
|
off_t offset);
|
||||||
|
|
||||||
virtual bool ValidateSetContentName(BString* name);
|
virtual status_t ValidateSetContentName(BString* name);
|
||||||
virtual bool ValidateSetName(const BMutablePartition* child,
|
virtual status_t ValidateSetName(const BMutablePartition* child,
|
||||||
BString* name);
|
BString* name);
|
||||||
virtual status_t SetContentName(const char* name);
|
virtual status_t SetContentName(const char* name);
|
||||||
virtual status_t SetName(BMutablePartition* child,
|
virtual status_t SetName(BMutablePartition* child,
|
||||||
const char* name);
|
const char* name);
|
||||||
|
|
||||||
virtual bool ValidateSetType(const BMutablePartition* child,
|
virtual status_t ValidateSetType(const BMutablePartition* child,
|
||||||
const char* type);
|
const char* type);
|
||||||
virtual status_t SetType(BMutablePartition* child,
|
virtual status_t SetType(BMutablePartition* child,
|
||||||
const char* type);
|
const char* type);
|
||||||
@@ -110,9 +110,9 @@ public:
|
|||||||
virtual status_t GetParameterEditor(
|
virtual status_t GetParameterEditor(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
BDiskDeviceParameterEditor** editor);
|
BDiskDeviceParameterEditor** editor);
|
||||||
virtual bool ValidateSetContentParameters(
|
virtual status_t ValidateSetContentParameters(
|
||||||
const char* parameters);
|
const char* parameters);
|
||||||
virtual bool ValidateSetParameters(
|
virtual status_t ValidateSetParameters(
|
||||||
const BMutablePartition* child,
|
const BMutablePartition* child,
|
||||||
const char* parameters);
|
const char* parameters);
|
||||||
virtual status_t SetContentParameters(const char* parameters);
|
virtual status_t SetContentParameters(const char* parameters);
|
||||||
@@ -122,11 +122,12 @@ public:
|
|||||||
virtual status_t GetChildCreationParameterEditor(
|
virtual status_t GetChildCreationParameterEditor(
|
||||||
const char* type,
|
const char* type,
|
||||||
BDiskDeviceParameterEditor** editor);
|
BDiskDeviceParameterEditor** editor);
|
||||||
virtual bool ValidateCreateChild(off_t* offset,
|
virtual status_t ValidateCreateChild(off_t* offset,
|
||||||
off_t* size, const char* type,
|
off_t* size, const char* type,
|
||||||
const char* parameters);
|
BString* name, const char* parameters);
|
||||||
virtual status_t CreateChild(off_t offset, off_t size,
|
virtual status_t CreateChild(off_t offset, off_t size,
|
||||||
const char* type, const char* parameters,
|
const char* type, const char* name,
|
||||||
|
const char* parameters,
|
||||||
BMutablePartition** child);
|
BMutablePartition** child);
|
||||||
|
|
||||||
virtual status_t DeleteChild(BMutablePartition* child);
|
virtual status_t DeleteChild(BMutablePartition* child);
|
||||||
|
|||||||
@@ -55,10 +55,16 @@ public:
|
|||||||
|
|
||||||
status_t CreateChild(int32 index,
|
status_t CreateChild(int32 index,
|
||||||
BMutablePartition** child);
|
BMutablePartition** child);
|
||||||
|
status_t CreateChild(int32 index, const char* type,
|
||||||
|
const char* name, const char* parameters,
|
||||||
|
BMutablePartition** child);
|
||||||
status_t DeleteChild(int32 index);
|
status_t DeleteChild(int32 index);
|
||||||
|
status_t DeleteChild(BMutablePartition* child);
|
||||||
|
|
||||||
|
BMutablePartition* Parent() const;
|
||||||
BMutablePartition* ChildAt(int32 index) const;
|
BMutablePartition* ChildAt(int32 index) const;
|
||||||
int32 CountChildren() const;
|
int32 CountChildren() const;
|
||||||
|
int32 IndexOfChild(BMutablePartition* child) const;
|
||||||
|
|
||||||
// for the partitioning system managing the parent
|
// for the partitioning system managing the parent
|
||||||
void* ChildCookie() const;
|
void* ChildCookie() const;
|
||||||
@@ -69,7 +75,8 @@ private:
|
|||||||
BPartition::MutableDelegate* delegate);
|
BPartition::MutableDelegate* delegate);
|
||||||
~BMutablePartition();
|
~BMutablePartition();
|
||||||
|
|
||||||
status_t Init(const user_partition_data* partitionData);
|
status_t Init(const user_partition_data* partitionData,
|
||||||
|
BMutablePartition* parent);
|
||||||
|
|
||||||
const user_partition_data* PartitionData() const;
|
const user_partition_data* PartitionData() const;
|
||||||
|
|
||||||
@@ -80,6 +87,7 @@ private:
|
|||||||
|
|
||||||
BPartition::MutableDelegate* fDelegate;
|
BPartition::MutableDelegate* fDelegate;
|
||||||
user_partition_data* fData;
|
user_partition_data* fData;
|
||||||
|
BMutablePartition* fParent;
|
||||||
BList fChildren;
|
BList fChildren;
|
||||||
void* fChildCookie;
|
void* fChildCookie;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ BDiskSystemAddOn::GetInitializationParameterEditor(
|
|||||||
|
|
||||||
|
|
||||||
// ValidateInitialize
|
// ValidateInitialize
|
||||||
bool
|
status_t
|
||||||
BDiskSystemAddOn::ValidateInitialize(const BMutablePartition* partition,
|
BDiskSystemAddOn::ValidateInitialize(const BMutablePartition* partition,
|
||||||
BString* name, const char* parameters)
|
BString* name, const char* parameters)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -176,19 +176,19 @@ BPartitionHandle::Repair(bool checkOnly)
|
|||||||
|
|
||||||
|
|
||||||
// ValidateResize
|
// ValidateResize
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateResize(off_t* size)
|
BPartitionHandle::ValidateResize(off_t* size)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ValidateResizeChild
|
// ValidateResizeChild
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateResizeChild(const BMutablePartition* child,
|
BPartitionHandle::ValidateResizeChild(const BMutablePartition* child,
|
||||||
off_t* size)
|
off_t* size)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -209,21 +209,21 @@ BPartitionHandle::ResizeChild(BMutablePartition* child, off_t size)
|
|||||||
|
|
||||||
|
|
||||||
// ValidateMove
|
// ValidateMove
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateMove(off_t* offset)
|
BPartitionHandle::ValidateMove(off_t* offset)
|
||||||
{
|
{
|
||||||
// Usually moving a disk system is a no-op for the content disk system,
|
// Usually moving a disk system is a no-op for the content disk system,
|
||||||
// so we default to true here.
|
// so we default to true here.
|
||||||
return true;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ValidateMoveChild
|
// ValidateMoveChild
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateMoveChild(const BMutablePartition* child,
|
BPartitionHandle::ValidateMoveChild(const BMutablePartition* child,
|
||||||
off_t* offset)
|
off_t* offset)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -246,19 +246,19 @@ BPartitionHandle::MoveChild(BMutablePartition* child, off_t offset)
|
|||||||
|
|
||||||
|
|
||||||
// ValidateSetContentName
|
// ValidateSetContentName
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateSetContentName(BString* name)
|
BPartitionHandle::ValidateSetContentName(BString* name)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ValidateSetName
|
// ValidateSetName
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateSetName(const BMutablePartition* child,
|
BPartitionHandle::ValidateSetName(const BMutablePartition* child,
|
||||||
BString* name)
|
BString* name)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -279,11 +279,11 @@ BPartitionHandle::SetName(BMutablePartition* child, const char* name)
|
|||||||
|
|
||||||
|
|
||||||
// ValidateSetType
|
// ValidateSetType
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateSetType(const BMutablePartition* child,
|
BPartitionHandle::ValidateSetType(const BMutablePartition* child,
|
||||||
const char* type)
|
const char* type)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -313,19 +313,19 @@ BPartitionHandle::GetParameterEditor(const BMutablePartition* child,
|
|||||||
|
|
||||||
|
|
||||||
// ValidateSetContentParameters
|
// ValidateSetContentParameters
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateSetContentParameters(const char* parameters)
|
BPartitionHandle::ValidateSetContentParameters(const char* parameters)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ValidateSetParameters
|
// ValidateSetParameters
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateSetParameters(const BMutablePartition* child,
|
BPartitionHandle::ValidateSetParameters(const BMutablePartition* child,
|
||||||
const char* parameters)
|
const char* parameters)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -356,18 +356,18 @@ BPartitionHandle::GetChildCreationParameterEditor(const char* type,
|
|||||||
|
|
||||||
|
|
||||||
// ValidateCreateChild
|
// ValidateCreateChild
|
||||||
bool
|
status_t
|
||||||
BPartitionHandle::ValidateCreateChild(off_t* offset, off_t* size,
|
BPartitionHandle::ValidateCreateChild(off_t* offset, off_t* size,
|
||||||
const char* type, const char* parameters)
|
const char* type, BString* name, const char* parameters)
|
||||||
{
|
{
|
||||||
return false;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CreateChild
|
// CreateChild
|
||||||
status_t
|
status_t
|
||||||
BPartitionHandle::CreateChild(off_t offset, off_t size, const char* type,
|
BPartitionHandle::CreateChild(off_t offset, off_t size, const char* type,
|
||||||
const char* parameters, BMutablePartition** child)
|
const char* name, const char* parameters, BMutablePartition** child)
|
||||||
{
|
{
|
||||||
return B_NOT_SUPPORTED;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,12 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <Partition.h>
|
||||||
|
|
||||||
#include <disk_device_manager/ddm_userland_interface.h>
|
#include <disk_device_manager/ddm_userland_interface.h>
|
||||||
|
|
||||||
|
#include "PartitionDelegate.h"
|
||||||
|
|
||||||
|
|
||||||
using std::nothrow;
|
using std::nothrow;
|
||||||
|
|
||||||
@@ -244,10 +248,68 @@ BMutablePartition::SetContentParameters(const char* parameters)
|
|||||||
|
|
||||||
// CreateChild
|
// CreateChild
|
||||||
status_t
|
status_t
|
||||||
BMutablePartition::CreateChild(int32 index, BMutablePartition** child)
|
BMutablePartition::CreateChild(int32 index, BMutablePartition** _child)
|
||||||
{
|
{
|
||||||
// TODO: ...
|
if (index < 0)
|
||||||
return B_ERROR;
|
index = fChildren.CountItems();
|
||||||
|
else if (index > fChildren.CountItems())
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
// create the BPartition
|
||||||
|
BPartition* partition = new(nothrow) BPartition;
|
||||||
|
if (!partition)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
// create the MutableDelegate
|
||||||
|
BPartition::MutableDelegate* delegate
|
||||||
|
= new(nothrow) BPartition::MutableDelegate(partition);
|
||||||
|
if (!delegate) {
|
||||||
|
delete partition;
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
partition->fDelegate = delegate;
|
||||||
|
// TODO: Any further initialization required?
|
||||||
|
|
||||||
|
// add the child
|
||||||
|
BMutablePartition* child = delegate->MutablePartition();
|
||||||
|
if (!fChildren.AddItem(child, index)) {
|
||||||
|
delete partition;
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
child->fParent = this;
|
||||||
|
|
||||||
|
*_child = child;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CreateChild
|
||||||
|
status_t
|
||||||
|
BMutablePartition::CreateChild(int32 index, const char* type, const char* name,
|
||||||
|
const char* parameters, BMutablePartition** _child)
|
||||||
|
{
|
||||||
|
// create the child
|
||||||
|
BMutablePartition* child;
|
||||||
|
status_t error = CreateChild(index, &child);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
// set the name, type, and parameters
|
||||||
|
error = SetType(type);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = SetName(name);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = SetParameters(parameters);
|
||||||
|
|
||||||
|
// cleanup on error
|
||||||
|
if (error != B_OK) {
|
||||||
|
DeleteChild(child);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
*_child = child;
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -255,8 +317,29 @@ BMutablePartition::CreateChild(int32 index, BMutablePartition** child)
|
|||||||
status_t
|
status_t
|
||||||
BMutablePartition::DeleteChild(int32 index)
|
BMutablePartition::DeleteChild(int32 index)
|
||||||
{
|
{
|
||||||
// TODO: ...
|
BMutablePartition* child = (BMutablePartition*)fChildren.RemoveItem(index);
|
||||||
return B_ERROR;
|
if (!child)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
delete child->fDelegate->Partition();
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DeleteChild
|
||||||
|
status_t
|
||||||
|
BMutablePartition::DeleteChild(BMutablePartition* child)
|
||||||
|
{
|
||||||
|
return DeleteChild(IndexOfChild(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parent
|
||||||
|
BMutablePartition*
|
||||||
|
BMutablePartition::Parent() const
|
||||||
|
{
|
||||||
|
return fParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -276,6 +359,16 @@ BMutablePartition::CountChildren() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IndexOfChild
|
||||||
|
int32
|
||||||
|
BMutablePartition::IndexOfChild(BMutablePartition* child) const
|
||||||
|
{
|
||||||
|
if (!child)
|
||||||
|
return -1;
|
||||||
|
return fChildren.IndexOf(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ChildCookie
|
// ChildCookie
|
||||||
void*
|
void*
|
||||||
BMutablePartition::ChildCookie() const
|
BMutablePartition::ChildCookie() const
|
||||||
@@ -296,6 +389,7 @@ BMutablePartition::SetChildCookie(void* cookie)
|
|||||||
BMutablePartition::BMutablePartition(BPartition::MutableDelegate* delegate)
|
BMutablePartition::BMutablePartition(BPartition::MutableDelegate* delegate)
|
||||||
: fDelegate(delegate),
|
: fDelegate(delegate),
|
||||||
fData(NULL),
|
fData(NULL),
|
||||||
|
fParent(NULL),
|
||||||
fChildCookie(NULL)
|
fChildCookie(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -303,8 +397,17 @@ BMutablePartition::BMutablePartition(BPartition::MutableDelegate* delegate)
|
|||||||
|
|
||||||
// Init
|
// Init
|
||||||
status_t
|
status_t
|
||||||
BMutablePartition::Init(const user_partition_data* partitionData)
|
BMutablePartition::Init(const user_partition_data* partitionData,
|
||||||
|
BMutablePartition* parent)
|
||||||
{
|
{
|
||||||
|
fParent = parent;
|
||||||
|
|
||||||
|
// add to the parent's child list
|
||||||
|
if (fParent) {
|
||||||
|
if (!fParent->fChildren.AddItem(this))
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
// allocate data structure
|
// allocate data structure
|
||||||
fData = new(nothrow) user_partition_data;
|
fData = new(nothrow) user_partition_data;
|
||||||
if (!fData)
|
if (!fData)
|
||||||
|
|||||||
@@ -61,14 +61,21 @@ BPartition::MutableDelegate::MutablePartition() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Init
|
// InitHierarchy
|
||||||
status_t
|
status_t
|
||||||
BPartition::MutableDelegate::Init(const user_partition_data* partitionData)
|
BPartition::MutableDelegate::InitHierarchy(
|
||||||
|
const user_partition_data* partitionData, Delegate* _parent)
|
||||||
{
|
{
|
||||||
status_t error = fMutablePartition.Init(partitionData);
|
MutableDelegate* parent = dynamic_cast<MutableDelegate*>(_parent);
|
||||||
if (error != B_OK)
|
return fMutablePartition.Init(partitionData,
|
||||||
return error;
|
parent ? &parent->fMutablePartition : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// InitAfterHierarchy
|
||||||
|
status_t
|
||||||
|
BPartition::MutableDelegate::InitAfterHierarchy()
|
||||||
|
{
|
||||||
if (!fMutablePartition.ContentType())
|
if (!fMutablePartition.ContentType())
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
@@ -80,13 +87,13 @@ BPartition::MutableDelegate::Init(const user_partition_data* partitionData)
|
|||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
BPartitionHandle* handle;
|
BPartitionHandle* handle;
|
||||||
error = addOn->CreatePartitionHandle(&fMutablePartition, &handle);
|
status_t error = addOn->CreatePartitionHandle(&fMutablePartition, &handle);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
manager->PutAddOn(addOn);
|
manager->PutAddOn(addOn);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything went fine --keep the disk system add-on reference and the
|
// everything went fine -- keep the disk system add-on reference and the
|
||||||
// handle
|
// handle
|
||||||
fDiskSystem = addOn;
|
fDiskSystem = addOn;
|
||||||
fPartitionHandle = handle;
|
fPartitionHandle = handle;
|
||||||
@@ -169,7 +176,7 @@ BPartition::MutableDelegate::ValidateResize(off_t* size) const
|
|||||||
if (!fPartitionHandle)
|
if (!fPartitionHandle)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateResize(size) ? B_OK : B_BAD_VALUE;
|
return fPartitionHandle->ValidateResize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,7 +191,7 @@ BPartition::MutableDelegate::ValidateResizeChild(Delegate* _child,
|
|||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateResizeChild(&child->fMutablePartition,
|
return fPartitionHandle->ValidateResizeChild(&child->fMutablePartition,
|
||||||
size) ? B_OK : B_BAD_VALUE;
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,7 +226,7 @@ BPartition::MutableDelegate::ValidateMove(off_t* offset) const
|
|||||||
if (!fPartitionHandle)
|
if (!fPartitionHandle)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateMove(offset) ? B_OK : B_BAD_VALUE;
|
return fPartitionHandle->ValidateMove(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,7 +241,7 @@ BPartition::MutableDelegate::ValidateMoveChild(Delegate* _child,
|
|||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateMoveChild(&child->fMutablePartition,
|
return fPartitionHandle->ValidateMoveChild(&child->fMutablePartition,
|
||||||
offset) ? B_OK : B_BAD_VALUE;
|
offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,7 +276,7 @@ BPartition::MutableDelegate::ValidateSetContentName(BString* name) const
|
|||||||
if (!fPartitionHandle)
|
if (!fPartitionHandle)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateSetContentName(name) ? B_OK : B_BAD_VALUE;
|
return fPartitionHandle->ValidateSetContentName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,8 +290,7 @@ BPartition::MutableDelegate::ValidateSetName(Delegate* _child,
|
|||||||
if (!fPartitionHandle || !child)
|
if (!fPartitionHandle || !child)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateSetName(&child->fMutablePartition, name)
|
return fPartitionHandle->ValidateSetName(&child->fMutablePartition, name);
|
||||||
? B_OK : B_BAD_VALUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -322,8 +328,7 @@ BPartition::MutableDelegate::ValidateSetType(Delegate* _child,
|
|||||||
if (!fPartitionHandle || !child)
|
if (!fPartitionHandle || !child)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateSetType(&child->fMutablePartition, type)
|
return fPartitionHandle->ValidateSetType(&child->fMutablePartition, type);
|
||||||
? B_OK : B_BAD_VALUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -444,13 +449,13 @@ BPartition::MutableDelegate::ValidateInitialize(const char* diskSystem,
|
|||||||
if (!addOn)
|
if (!addOn)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
bool result = addOn->ValidateInitialize(&fMutablePartition,
|
status_t result = addOn->ValidateInitialize(&fMutablePartition,
|
||||||
name, parameters);
|
name, parameters);
|
||||||
|
|
||||||
// put the add-on
|
// put the add-on
|
||||||
manager->PutAddOn(addOn);
|
manager->PutAddOn(addOn);
|
||||||
|
|
||||||
return result ? B_OK : B_BAD_VALUE;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -513,26 +518,27 @@ BPartition::MutableDelegate::GetChildCreationParameterEditor(const char* type,
|
|||||||
// ValidateCreateChild
|
// ValidateCreateChild
|
||||||
status_t
|
status_t
|
||||||
BPartition::MutableDelegate::ValidateCreateChild(off_t* start, off_t* size,
|
BPartition::MutableDelegate::ValidateCreateChild(off_t* start, off_t* size,
|
||||||
const char* type, const char* parameters) const
|
const char* type, BString* name, const char* parameters) const
|
||||||
{
|
{
|
||||||
if (!fPartitionHandle)
|
if (!fPartitionHandle)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return fPartitionHandle->ValidateCreateChild(start, size, type, parameters)
|
return fPartitionHandle->ValidateCreateChild(start, size, type, name,
|
||||||
? B_OK : B_BAD_VALUE;
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CreateChild
|
// CreateChild
|
||||||
status_t
|
status_t
|
||||||
BPartition::MutableDelegate::CreateChild(off_t start, off_t size,
|
BPartition::MutableDelegate::CreateChild(off_t start, off_t size,
|
||||||
const char* type, const char* parameters, BPartition** child)
|
const char* type, const char* name, const char* parameters,
|
||||||
|
BPartition** child)
|
||||||
{
|
{
|
||||||
if (!fPartitionHandle)
|
if (!fPartitionHandle)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
BMutablePartition* mutableChild;
|
BMutablePartition* mutableChild;
|
||||||
status_t error = fPartitionHandle->CreateChild(start, size, type,
|
status_t error = fPartitionHandle->CreateChild(start, size, type, name,
|
||||||
parameters, &mutableChild);
|
parameters, &mutableChild);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ public:
|
|||||||
Delegate(BPartition* partition);
|
Delegate(BPartition* partition);
|
||||||
virtual ~Delegate();
|
virtual ~Delegate();
|
||||||
|
|
||||||
virtual status_t Init(const user_partition_data* partitionData)
|
virtual status_t InitHierarchy(
|
||||||
= 0;
|
const user_partition_data* partitionData,
|
||||||
|
Delegate* parent) = 0;
|
||||||
|
virtual status_t InitAfterHierarchy() = 0;
|
||||||
|
|
||||||
BPartition* Partition() const { return fPartition; }
|
BPartition* Partition() const { return fPartition; }
|
||||||
|
|
||||||
@@ -89,10 +91,11 @@ public:
|
|||||||
BDiskDeviceParameterEditor** editor)
|
BDiskDeviceParameterEditor** editor)
|
||||||
const = 0;
|
const = 0;
|
||||||
virtual status_t ValidateCreateChild(off_t* start, off_t* size,
|
virtual status_t ValidateCreateChild(off_t* start, off_t* size,
|
||||||
const char* type,
|
const char* type, BString* name,
|
||||||
const char* parameters) const = 0;
|
const char* parameters) const = 0;
|
||||||
virtual status_t CreateChild(off_t start, off_t size,
|
virtual status_t CreateChild(off_t start, off_t size,
|
||||||
const char* type, const char* parameters,
|
const char* type, const char* name,
|
||||||
|
const char* parameters,
|
||||||
BPartition** child) = 0;
|
BPartition** child) = 0;
|
||||||
|
|
||||||
virtual status_t DeleteChild(Delegate* child) = 0;
|
virtual status_t DeleteChild(Delegate* child) = 0;
|
||||||
@@ -103,7 +106,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BPartition::MutableDelegate : BPartition::Delegate {
|
class BPartition::MutableDelegate : public BPartition::Delegate {
|
||||||
public:
|
public:
|
||||||
MutableDelegate(BPartition* partition);
|
MutableDelegate(BPartition* partition);
|
||||||
virtual ~MutableDelegate();
|
virtual ~MutableDelegate();
|
||||||
@@ -111,7 +114,10 @@ public:
|
|||||||
BMutablePartition* MutablePartition();
|
BMutablePartition* MutablePartition();
|
||||||
const BMutablePartition* MutablePartition() const;
|
const BMutablePartition* MutablePartition() const;
|
||||||
|
|
||||||
virtual status_t Init(const user_partition_data* partitionData);
|
virtual status_t InitHierarchy(
|
||||||
|
const user_partition_data* partitionData,
|
||||||
|
Delegate* parent);
|
||||||
|
virtual status_t InitAfterHierarchy();
|
||||||
|
|
||||||
virtual const user_partition_data* PartitionData() const;
|
virtual const user_partition_data* PartitionData() const;
|
||||||
|
|
||||||
@@ -127,17 +133,17 @@ public:
|
|||||||
virtual status_t Defragment();
|
virtual status_t Defragment();
|
||||||
virtual status_t Repair(bool checkOnly);
|
virtual status_t Repair(bool checkOnly);
|
||||||
|
|
||||||
virtual status_t ValidateResize(off_t* size) const = 0;
|
virtual status_t ValidateResize(off_t* size) const;
|
||||||
virtual status_t ValidateResizeChild(Delegate* child,
|
virtual status_t ValidateResizeChild(Delegate* child,
|
||||||
off_t* size) const = 0;
|
off_t* size) const;
|
||||||
virtual status_t Resize(off_t size) = 0;
|
virtual status_t Resize(off_t size);
|
||||||
virtual status_t ResizeChild(Delegate* child, off_t size) = 0;
|
virtual status_t ResizeChild(Delegate* child, off_t size);
|
||||||
|
|
||||||
virtual status_t ValidateMove(off_t* offset) const = 0;
|
virtual status_t ValidateMove(off_t* offset) const;
|
||||||
virtual status_t ValidateMoveChild(Delegate* child,
|
virtual status_t ValidateMoveChild(Delegate* child,
|
||||||
off_t* offset) const = 0;
|
off_t* offset) const;
|
||||||
virtual status_t Move(off_t offset) = 0;
|
virtual status_t Move(off_t offset);
|
||||||
virtual status_t MoveChild(Delegate* child, off_t offset) = 0;
|
virtual status_t MoveChild(Delegate* child, off_t offset);
|
||||||
|
|
||||||
virtual status_t ValidateSetContentName(BString* name) const;
|
virtual status_t ValidateSetContentName(BString* name) const;
|
||||||
virtual status_t ValidateSetName(Delegate* child,
|
virtual status_t ValidateSetName(Delegate* child,
|
||||||
@@ -174,11 +180,11 @@ public:
|
|||||||
const char* system,
|
const char* system,
|
||||||
BDiskDeviceParameterEditor** editor) const;
|
BDiskDeviceParameterEditor** editor) const;
|
||||||
virtual status_t ValidateCreateChild(off_t* start, off_t* size,
|
virtual status_t ValidateCreateChild(off_t* start, off_t* size,
|
||||||
const char* type,
|
const char* type, BString* name,
|
||||||
const char* parameters) const;
|
const char* parameters) const;
|
||||||
virtual status_t CreateChild(off_t start, off_t size,
|
virtual status_t CreateChild(off_t start, off_t size,
|
||||||
const char* type, const char* parameters,
|
const char* type, const char* name,
|
||||||
BPartition** child);
|
const char* parameters, BPartition** child);
|
||||||
|
|
||||||
virtual status_t DeleteChild(Delegate* child);
|
virtual status_t DeleteChild(Delegate* child);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user