Implemented all read-only (more precisely: not writing) methods. Small changes.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4034 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2003-07-20 17:24:32 +00:00
parent fb82e723f2
commit d7ce4fddfc
@@ -81,18 +81,24 @@ KPartitioningSystem::FreeIdentifyCookie(KPartition *partition, void *cookie)
void void
KPartitioningSystem::FreeCookie(KPartition *partition) KPartitioningSystem::FreeCookie(KPartition *partition)
{ {
if (!partition || !fModule || !fModule->free_partition_cookie) if (!partition || !fModule || !fModule->free_partition_cookie
|| partition->ParentDiskSystem() != this) {
return; return;
}
fModule->free_partition_cookie(partition->PartitionData()); fModule->free_partition_cookie(partition->PartitionData());
partition->SetCookie(NULL);
} }
// FreeContentCookie // FreeContentCookie
void void
KPartitioningSystem::FreeContentCookie(KPartition *partition) KPartitioningSystem::FreeContentCookie(KPartition *partition)
{ {
if (!partition || !fModule || !fModule->free_partition_content_cookie) if (!partition || !fModule || !fModule->free_partition_content_cookie
|| partition->DiskSystem() != this) {
return; return;
}
fModule->free_partition_content_cookie(partition->PartitionData()); fModule->free_partition_content_cookie(partition->PartitionData());
partition->SetContentCookie(NULL);
} }
// SupportsRepairing // SupportsRepairing
@@ -100,10 +106,17 @@ bool
KPartitioningSystem::SupportsRepairing(KPartition *partition, bool checkOnly, KPartitioningSystem::SupportsRepairing(KPartition *partition, bool checkOnly,
bool *whileMounted) bool *whileMounted)
{ {
// to be implemented bool _whileMounted = false;
if (whileMounted) if (!whileMounted)
*whileMounted = false; whileMounted = &_whileMounted;
return false; if (!partition || partition->DiskSystem() != this || !fModule
|| !fModule->supports_repairing) {
return (*whileMounted = false);
}
bool result = fModule->supports_repairing(partition->PartitionData(),
checkOnly);
*whileMounted = result;
return result;
} }
// SupportsResizing // SupportsResizing
@@ -111,42 +124,60 @@ bool
KPartitioningSystem::SupportsResizing(KPartition *partition, KPartitioningSystem::SupportsResizing(KPartition *partition,
bool *whileMounted) bool *whileMounted)
{ {
// to be implemented bool _whileMounted = false;
if (whileMounted) if (!whileMounted)
*whileMounted = false; whileMounted = &_whileMounted;
return false; if (!partition || partition->DiskSystem() != this || !fModule ||
!fModule->supports_resizing) {
return (*whileMounted = false);
}
bool result = fModule->supports_resizing(partition->PartitionData());
*whileMounted = result;
return result;
} }
// SupportsResizingChild // SupportsResizingChild
bool bool
KPartitioningSystem::SupportsResizingChild(KPartition *child) KPartitioningSystem::SupportsResizingChild(KPartition *child)
{ {
// to be implemented return (child && child->Parent() && child->ParentDiskSystem() == this
return false; && fModule && fModule->supports_resizing_child
&& fModule->supports_resizing_child(
child->Parent()->PartitionData(),
child->PartitionData()));
} }
// SupportsMoving // SupportsMoving
bool bool
KPartitioningSystem::SupportsMoving(KPartition *partition, bool *isNoOp) KPartitioningSystem::SupportsMoving(KPartition *partition, bool *isNoOp)
{ {
// to be implemented bool _isNoOp = false;
return false; if (!isNoOp)
isNoOp = &_isNoOp;
if (!partition || partition->DiskSystem() != this || !fModule
|| !fModule->supports_moving) {
return (*isNoOp = false);
}
return fModule->supports_moving(partition->PartitionData(), isNoOp);
} }
// SupportsMovingChild // SupportsMovingChild
bool bool
KPartitioningSystem::SupportsMovingChild(KPartition *child) KPartitioningSystem::SupportsMovingChild(KPartition *child)
{ {
// to be implemented return (child && child->Parent() && child->ParentDiskSystem() != this
return false; && fModule && fModule->supports_moving_child
&& fModule->supports_moving_child(child->Parent()->PartitionData(),
child->PartitionData()));
} }
// SupportsSettingName // SupportsSettingName
bool bool
KPartitioningSystem::SupportsSettingName(KPartition *partition) KPartitioningSystem::SupportsSettingName(KPartition *partition)
{ {
// to be implemented return (partition && partition->ParentDiskSystem() == this
return false; && fModule && fModule->supports_setting_name
&& fModule->supports_setting_name(partition->PartitionData()));
} }
// SupportsSettingContentName // SupportsSettingContentName
@@ -154,24 +185,36 @@ bool
KPartitioningSystem::SupportsSettingContentName(KPartition *partition, KPartitioningSystem::SupportsSettingContentName(KPartition *partition,
bool *whileMounted) bool *whileMounted)
{ {
// to be implemented bool _whileMounted = false;
return false; if (!whileMounted)
whileMounted = &_whileMounted;
if (!partition || partition->DiskSystem() != this || !fModule
|| !fModule->supports_setting_content_name) {
return (*whileMounted = false);
}
bool result = fModule->supports_setting_content_name(
partition->PartitionData());
*whileMounted = result;
return result;
} }
// SupportsSettingType // SupportsSettingType
bool bool
KPartitioningSystem::SupportsSettingType(KPartition *partition) KPartitioningSystem::SupportsSettingType(KPartition *partition)
{ {
// to be implemented return (partition && partition->ParentDiskSystem() == this
return false; && fModule && fModule->supports_setting_type
&& fModule->supports_setting_type(partition->PartitionData()));
} }
// SupportsSettingParameters // SupportsSettingParameters
bool bool
KPartitioningSystem::SupportsSettingParameters(KPartition *partition) KPartitioningSystem::SupportsSettingParameters(KPartition *partition)
{ {
// to be implemented return (partition && partition->ParentDiskSystem() == this
return false; && fModule && fModule->supports_setting_parameters
&& fModule->supports_setting_parameters(
partition->PartitionData()));
} }
// SupportsSettingContentParameters // SupportsSettingContentParameters
@@ -179,16 +222,25 @@ bool
KPartitioningSystem::SupportsSettingContentParameters(KPartition *partition, KPartitioningSystem::SupportsSettingContentParameters(KPartition *partition,
bool *whileMounted) bool *whileMounted)
{ {
// to be implemented bool _whileMounted = false;
return false; if (!whileMounted)
whileMounted = &_whileMounted;
if (!partition || partition->DiskSystem() != this || !fModule
|| !fModule->supports_setting_content_parameters) {
return (*whileMounted = false);
}
bool result = fModule->supports_setting_content_parameters(
partition->PartitionData());
*whileMounted = result;
return result;
} }
// SupportsInitializing // SupportsInitializing
bool bool
KPartitioningSystem::SupportsInitializing(KPartition *partition) KPartitioningSystem::SupportsInitializing(KPartition *partition)
{ {
// to be implemented return (partition && fModule && fModule->supports_initializing
return false; && fModule->supports_initializing(partition->PartitionData()));
} }
// SupportsInitializingChild // SupportsInitializingChild
@@ -196,88 +248,106 @@ bool
KPartitioningSystem::SupportsInitializingChild(KPartition *child, KPartitioningSystem::SupportsInitializingChild(KPartition *child,
const char *diskSystem) const char *diskSystem)
{ {
// to be implemented return (child && child->ParentDiskSystem() == this && diskSystem
return false; && fModule && fModule->supports_initializing_child
&& fModule->supports_initializing_child(child->PartitionData(),
diskSystem));
} }
// SupportsCreatingChild // SupportsCreatingChild
bool bool
KPartitioningSystem::SupportsCreatingChild(KPartition *partition) KPartitioningSystem::SupportsCreatingChild(KPartition *partition)
{ {
// to be implemented return (partition && partition->DiskSystem() == this
return false; && fModule && fModule->supports_creating_child
&& fModule->supports_creating_child(partition->PartitionData()));
} }
// SupportsDeletingChild // SupportsDeletingChild
bool bool
KPartitioningSystem::SupportsDeletingChild(KPartition *child) KPartitioningSystem::SupportsDeletingChild(KPartition *child)
{ {
// to be implemented return (child && child->Parent() && child->ParentDiskSystem() == this
return false; && fModule && fModule->supports_deleting_child
&& fModule->supports_deleting_child(
child->Parent()->PartitionData(), child->PartitionData()));
} }
// IsSubSystemFor // IsSubSystemFor
bool bool
KPartitioningSystem::IsSubSystemFor(KPartition *partition) KPartitioningSystem::IsSubSystemFor(KPartition *partition)
{ {
// to be implemented return (partition && fModule && fModule->is_sub_system_for
return false; && fModule->is_sub_system_for(partition->PartitionData()));
} }
// ValidateResize // ValidateResize
bool bool
KPartitioningSystem::ValidateResize(KPartition *partition, off_t *size) KPartitioningSystem::ValidateResize(KPartition *partition, off_t *size)
{ {
// to be implemented return (partition && size && partition->DiskSystem() == this && fModule
return false; && fModule->validate_resize
&& fModule->validate_resize(partition->PartitionData(), size));
} }
// ValidateResizeChild // ValidateResizeChild
bool bool
KPartitioningSystem::ValidateResizeChild(KPartition *partition, off_t *size) KPartitioningSystem::ValidateResizeChild(KPartition *child, off_t *size)
{ {
// to be implemented return (child && size && child->Parent()
return false; && child->ParentDiskSystem() == this && fModule
&& fModule->validate_resize_child
&& fModule->validate_resize_child(child->Parent()->PartitionData(),
child->PartitionData(), size));
} }
// ValidateMove // ValidateMove
bool bool
KPartitioningSystem::ValidateMove(KPartition *partition, off_t *start) KPartitioningSystem::ValidateMove(KPartition *partition, off_t *start)
{ {
// to be implemented return (partition && start && partition->DiskSystem() == this && fModule
return false; && fModule->validate_move
&& fModule->validate_move(partition->PartitionData(), start));
} }
// ValidateMoveChild // ValidateMoveChild
bool bool
KPartitioningSystem::ValidateMoveChild(KPartition *partition, off_t *start) KPartitioningSystem::ValidateMoveChild(KPartition *child, off_t *start)
{ {
// to be implemented return (child && start && child->Parent()
return false; && child->ParentDiskSystem() == this && fModule
&& fModule->validate_move_child
&& fModule->validate_move_child(child->Parent()->PartitionData(),
child->PartitionData(), start));
} }
// ValidateSetName // ValidateSetName
bool bool
KPartitioningSystem::ValidateSetName(KPartition *partition, char *name) KPartitioningSystem::ValidateSetName(KPartition *partition, char *name)
{ {
// to be implemented return (partition && name && partition->Parent()
return false; && partition->ParentDiskSystem() == this && fModule
&& fModule->validate_set_name
&& fModule->validate_set_name(partition->PartitionData(), name));
} }
// ValidateSetContentName // ValidateSetContentName
bool bool
KPartitioningSystem::ValidateSetContentName(KPartition *partition, char *name) KPartitioningSystem::ValidateSetContentName(KPartition *partition, char *name)
{ {
// to be implemented return (partition && name && partition->DiskSystem() == this
return false; && fModule && fModule->validate_set_content_name
&& fModule->validate_set_content_name(partition->PartitionData(),
name));
} }
// ValidateSetType // ValidateSetType
bool bool
KPartitioningSystem::ValidateSetType(KPartition *partition, const char *type) KPartitioningSystem::ValidateSetType(KPartition *partition, const char *type)
{ {
// to be implemented return (partition && type && partition->ParentDiskSystem() == this
return false; && fModule && fModule->validate_set_type
&& fModule->validate_set_type(partition->PartitionData(), type));
} }
// ValidateSetParameters // ValidateSetParameters
@@ -285,17 +355,21 @@ bool
KPartitioningSystem::ValidateSetParameters(KPartition *partition, KPartitioningSystem::ValidateSetParameters(KPartition *partition,
const char *parameters) const char *parameters)
{ {
// to be implemented return (partition && partition->ParentDiskSystem() == this
return false; && fModule && fModule->validate_set_parameters
&& fModule->validate_set_parameters(partition->PartitionData(),
parameters));
} }
// ValidateSetContentParameters // ValidateSetContentParameters
bool bool
KPartitioningSystem::ValidateSetContentParameters(KPartition *child, KPartitioningSystem::ValidateSetContentParameters(KPartition *partition,
const char *parameters) const char *parameters)
{ {
// to be implemented return (partition && partition->DiskSystem() == this && fModule
return false; && fModule->validate_set_content_parameters
&& fModule->validate_set_content_parameters(
partition->PartitionData(), parameters));
} }
// ValidateInitialize // ValidateInitialize
@@ -303,8 +377,9 @@ bool
KPartitioningSystem::ValidateInitialize(KPartition *partition, char *name, KPartitioningSystem::ValidateInitialize(KPartition *partition, char *name,
const char *parameters) const char *parameters)
{ {
// to be implemented return (partition && name && fModule && fModule->validate_initialize
return false; && fModule->validate_initialize(partition->PartitionData(), name,
parameters));
} }
// ValidateCreateChild // ValidateCreateChild
@@ -313,26 +388,45 @@ KPartitioningSystem::ValidateCreateChild(KPartition *partition, off_t *start,
off_t *size, const char *type, off_t *size, const char *type,
const char *parameters) const char *parameters)
{ {
// to be implemented return (partition && start && size && type
return false; && partition->DiskSystem() == this && fModule
&& fModule->validate_create_child
&& fModule->validate_create_child(partition->PartitionData(),
start, size, type, parameters));
} }
// CountPartitionableSpaces // CountPartitionableSpaces
int32 int32
KPartitioningSystem::CountPartitionableSpaces(KPartition *partition) KPartitioningSystem::CountPartitionableSpaces(KPartition *partition)
{ {
// to be implemented if (!partition || partition->DiskSystem() != this || !fModule)
return 0; return 0;
if (!fModule->get_partitionable_spaces) {
// TODO: Fallback algorithm.
return 0;
}
int32 count = 0;
status_t error = fModule->get_partitionable_spaces(
partition->PartitionData(), NULL, 0, &count);
return (error == B_OK || error == B_BUFFER_OVERFLOW ? count : 0);
} }
// GetPartitionableSpaces // GetPartitionableSpaces
bool status_t
KPartitioningSystem::GetPartitionableSpaces(KPartition *partition, KPartitioningSystem::GetPartitionableSpaces(KPartition *partition,
partitionable_space_data *spaces, partitionable_space_data *buffer,
int32 count, int32 *actualCount) int32 count, int32 *actualCount)
{ {
// to be implemented if (!partition || partition->DiskSystem() != this || count > 0 && !buffer
return false; || !actualCount || !fModule) {
return B_BAD_VALUE;
}
if (!fModule->get_partitionable_spaces) {
// TODO: Fallback algorithm.
return B_ENTRY_NOT_FOUND;
}
return fModule->get_partitionable_spaces(partition->PartitionData(),
buffer, count, actualCount);
} }
// GetNextSupportedType // GetNextSupportedType
@@ -340,16 +434,25 @@ status_t
KPartitioningSystem::GetNextSupportedType(KPartition *partition, int32 *cookie, KPartitioningSystem::GetNextSupportedType(KPartition *partition, int32 *cookie,
char *type) char *type)
{ {
// to be implemented if (!partition || partition->DiskSystem() != this || !cookie || !type
return B_ERROR; || !fModule) {
return B_BAD_VALUE;
}
if (!fModule->get_next_supported_type)
return B_ENTRY_NOT_FOUND;
return fModule->get_next_supported_type(partition->PartitionData(), cookie,
type);
} }
// GetTypeForContentType // GetTypeForContentType
status_t status_t
KPartitioningSystem::GetTypeForContentType(const char *contentType, char *type) KPartitioningSystem::GetTypeForContentType(const char *contentType, char *type)
{ {
// to be implemented if (!contentType || !type || !fModule)
return B_ERROR; return B_BAD_VALUE;
if (!fModule->get_type_for_content_type)
return B_ENTRY_NOT_FOUND;
return fModule->get_type_for_content_type(contentType, type);
} }
// Repair // Repair