* Style cleanup.
* Moved method documentation from headers to source files. * Fixed small problems (memory leaks, unsafe string duplication,...). * Added TODOs where I spotted problems. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
* Lubos Kulic <[email protected]>
|
||||
*/
|
||||
|
||||
/** \file KPartitioningSystem.cpp
|
||||
*
|
||||
* \brief Implementation of \ref KPartitioningSystem class
|
||||
@@ -15,6 +24,7 @@
|
||||
#include <KPartition.h>
|
||||
#include <KPartitioningSystem.h>
|
||||
|
||||
|
||||
// constructor
|
||||
KPartitioningSystem::KPartitioningSystem(const char *name)
|
||||
: KDiskSystem(name),
|
||||
@@ -44,6 +54,7 @@ KPartitioningSystem::Init()
|
||||
}
|
||||
|
||||
// Identify
|
||||
//! Try to identify a given partition
|
||||
float
|
||||
KPartitioningSystem::Identify(KPartition *partition, void **cookie)
|
||||
{
|
||||
@@ -53,12 +64,13 @@ KPartitioningSystem::Identify(KPartition *partition, void **cookie)
|
||||
if (partition->Open(O_RDONLY, &fd) != B_OK)
|
||||
return -1;
|
||||
float result = fModule->identify_partition(fd, partition->PartitionData(),
|
||||
cookie);
|
||||
cookie);
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Scan
|
||||
//! Scan the partition
|
||||
status_t
|
||||
KPartitioningSystem::Scan(KPartition *partition, void *cookie)
|
||||
{
|
||||
@@ -80,7 +92,7 @@ KPartitioningSystem::FreeIdentifyCookie(KPartition *partition, void *cookie)
|
||||
if (!partition || !fModule || !fModule->free_identify_partition_cookie)
|
||||
return;
|
||||
fModule->free_identify_partition_cookie(partition->PartitionData(),
|
||||
cookie);
|
||||
cookie);
|
||||
}
|
||||
|
||||
// FreeCookie
|
||||
@@ -108,9 +120,10 @@ KPartitioningSystem::FreeContentCookie(KPartition *partition)
|
||||
}
|
||||
|
||||
// SupportsRepairing
|
||||
//! Check whether the add-on supports repairing this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsRepairing(KPartition *partition, bool checkOnly,
|
||||
bool *whileMounted)
|
||||
bool *whileMounted)
|
||||
{
|
||||
bool _whileMounted = false;
|
||||
if (!whileMounted)
|
||||
@@ -126,9 +139,9 @@ KPartitioningSystem::SupportsRepairing(KPartition *partition, bool checkOnly,
|
||||
}
|
||||
|
||||
// SupportsResizing
|
||||
//! Check whether the add-on supports resizing this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsResizing(KPartition *partition,
|
||||
bool *whileMounted)
|
||||
KPartitioningSystem::SupportsResizing(KPartition *partition, bool *whileMounted)
|
||||
{
|
||||
bool _whileMounted = false;
|
||||
if (!whileMounted)
|
||||
@@ -143,17 +156,18 @@ KPartitioningSystem::SupportsResizing(KPartition *partition,
|
||||
}
|
||||
|
||||
// SupportsResizingChild
|
||||
//! Check whether the add-on supports resizing children of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsResizingChild(KPartition *child)
|
||||
{
|
||||
return (child && child->Parent() && child->ParentDiskSystem() == this
|
||||
&& fModule && fModule->supports_resizing_child
|
||||
&& fModule->supports_resizing_child(
|
||||
child->Parent()->PartitionData(),
|
||||
child->PartitionData()));
|
||||
&& fModule && fModule->supports_resizing_child
|
||||
&& fModule->supports_resizing_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsMoving
|
||||
//! Check whether the add-on supports moving this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsMoving(KPartition *partition, bool *isNoOp)
|
||||
{
|
||||
@@ -168,28 +182,33 @@ KPartitioningSystem::SupportsMoving(KPartition *partition, bool *isNoOp)
|
||||
}
|
||||
|
||||
// SupportsMovingChild
|
||||
//! Check whether the add-on supports moving children of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsMovingChild(KPartition *child)
|
||||
{
|
||||
return (child && child->Parent() && child->ParentDiskSystem() != this
|
||||
&& fModule && fModule->supports_moving_child
|
||||
&& fModule->supports_moving_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData()));
|
||||
&& fModule && fModule->supports_moving_child
|
||||
&& fModule->supports_moving_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsSettingName
|
||||
//! Check whether the add-on supports setting name of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsSettingName(KPartition *partition)
|
||||
{
|
||||
return (partition && partition->ParentDiskSystem() == this
|
||||
&& fModule && fModule->supports_setting_name
|
||||
&& fModule->supports_setting_name(partition->PartitionData()));
|
||||
&& fModule && fModule->supports_setting_name
|
||||
&& fModule->supports_setting_name(partition->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsSettingContentName
|
||||
/*! Check whether the add-on supports setting name of the content of this
|
||||
partition.
|
||||
*/
|
||||
bool
|
||||
KPartitioningSystem::SupportsSettingContentName(KPartition *partition,
|
||||
bool *whileMounted)
|
||||
bool *whileMounted)
|
||||
{
|
||||
bool _whileMounted = false;
|
||||
if (!whileMounted)
|
||||
@@ -205,28 +224,32 @@ KPartitioningSystem::SupportsSettingContentName(KPartition *partition,
|
||||
}
|
||||
|
||||
// SupportsSettingType
|
||||
//! Check whether the add-on supports setting type of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsSettingType(KPartition *partition)
|
||||
{
|
||||
return (partition && partition->ParentDiskSystem() == this
|
||||
&& fModule && fModule->supports_setting_type
|
||||
&& fModule->supports_setting_type(partition->PartitionData()));
|
||||
&& fModule && fModule->supports_setting_type
|
||||
&& fModule->supports_setting_type(partition->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsSettingParameters
|
||||
//! Check whether the add-on supports setting parameters of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsSettingParameters(KPartition *partition)
|
||||
{
|
||||
return (partition && partition->ParentDiskSystem() == this
|
||||
&& fModule && fModule->supports_setting_parameters
|
||||
&& fModule->supports_setting_parameters(
|
||||
partition->PartitionData()));
|
||||
&& fModule && fModule->supports_setting_parameters
|
||||
&& fModule->supports_setting_parameters(partition->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsSettingContentParameters
|
||||
/*! Check whether the add-on supports setting parameters of the content of this
|
||||
partition.
|
||||
*/
|
||||
bool
|
||||
KPartitioningSystem::SupportsSettingContentParameters(KPartition *partition,
|
||||
bool *whileMounted)
|
||||
bool *whileMounted)
|
||||
{
|
||||
bool _whileMounted = false;
|
||||
if (!whileMounted)
|
||||
@@ -242,135 +265,149 @@ KPartitioningSystem::SupportsSettingContentParameters(KPartition *partition,
|
||||
}
|
||||
|
||||
// SupportsInitializing
|
||||
//! Check whether the add-on supports initializing this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsInitializing(KPartition *partition)
|
||||
{
|
||||
return (partition && fModule && fModule->supports_initializing
|
||||
&& fModule->supports_initializing(partition->PartitionData()));
|
||||
&& fModule->supports_initializing(partition->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsInitializingChild
|
||||
//! Check whether the add-on supports initializing a child of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsInitializingChild(KPartition *child,
|
||||
const char *diskSystem)
|
||||
const char *diskSystem)
|
||||
{
|
||||
return (child && child->ParentDiskSystem() == this && diskSystem
|
||||
&& fModule && fModule->supports_initializing_child
|
||||
&& fModule->supports_initializing_child(child->PartitionData(),
|
||||
diskSystem));
|
||||
&& fModule && fModule->supports_initializing_child
|
||||
&& fModule->supports_initializing_child(child->PartitionData(),
|
||||
diskSystem));
|
||||
}
|
||||
|
||||
// SupportsCreatingChild
|
||||
//! Check whether the add-on supports creating children of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsCreatingChild(KPartition *partition)
|
||||
{
|
||||
return (partition && partition->DiskSystem() == this
|
||||
&& fModule && fModule->supports_creating_child
|
||||
&& fModule->supports_creating_child(partition->PartitionData()));
|
||||
&& fModule && fModule->supports_creating_child
|
||||
&& fModule->supports_creating_child(partition->PartitionData()));
|
||||
}
|
||||
|
||||
// SupportsDeletingChild
|
||||
//! Check whether the add-on supports deleting children of this partition.
|
||||
bool
|
||||
KPartitioningSystem::SupportsDeletingChild(KPartition *child)
|
||||
{
|
||||
return (child && child->Parent() && child->ParentDiskSystem() == this
|
||||
&& fModule && fModule->supports_deleting_child
|
||||
&& fModule->supports_deleting_child(
|
||||
child->Parent()->PartitionData(), child->PartitionData()));
|
||||
&& fModule && fModule->supports_deleting_child
|
||||
&& fModule->supports_deleting_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData()));
|
||||
}
|
||||
|
||||
// IsSubSystemFor
|
||||
//! Check whether the add-on is a subsystem for a given partition.
|
||||
bool
|
||||
KPartitioningSystem::IsSubSystemFor(KPartition *partition)
|
||||
{
|
||||
return (partition && fModule && fModule->is_sub_system_for
|
||||
&& fModule->is_sub_system_for(partition->PartitionData()));
|
||||
&& fModule->is_sub_system_for(partition->PartitionData()));
|
||||
}
|
||||
|
||||
// ValidateResize
|
||||
//! Validates parameters for resizing a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateResize(KPartition *partition, off_t *size)
|
||||
{
|
||||
return (partition && size && partition->DiskSystem() == this && fModule
|
||||
&& fModule->validate_resize
|
||||
&& fModule->validate_resize(partition->PartitionData(), size));
|
||||
&& fModule->validate_resize
|
||||
&& fModule->validate_resize(partition->PartitionData(), size));
|
||||
}
|
||||
|
||||
// ValidateResizeChild
|
||||
//! Validates parameters for resizing a child partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateResizeChild(KPartition *child, off_t *size)
|
||||
{
|
||||
return (child && size && child->Parent()
|
||||
&& child->ParentDiskSystem() == this && fModule
|
||||
&& fModule->validate_resize_child
|
||||
&& fModule->validate_resize_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData(), size));
|
||||
&& child->ParentDiskSystem() == this && fModule
|
||||
&& fModule->validate_resize_child
|
||||
&& fModule->validate_resize_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData(), size));
|
||||
}
|
||||
|
||||
// ValidateMove
|
||||
//! Validates parameters for moving a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateMove(KPartition *partition, off_t *start)
|
||||
{
|
||||
return (partition && start && partition->DiskSystem() == this && fModule
|
||||
&& fModule->validate_move
|
||||
&& fModule->validate_move(partition->PartitionData(), start));
|
||||
&& fModule->validate_move
|
||||
&& fModule->validate_move(partition->PartitionData(), start));
|
||||
}
|
||||
|
||||
// ValidateMoveChild
|
||||
//! Validates parameters for moving a child partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateMoveChild(KPartition *child, off_t *start)
|
||||
{
|
||||
return (child && start && child->Parent()
|
||||
&& child->ParentDiskSystem() == this && fModule
|
||||
&& fModule->validate_move_child
|
||||
&& fModule->validate_move_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData(), start));
|
||||
&& child->ParentDiskSystem() == this && fModule
|
||||
&& fModule->validate_move_child
|
||||
&& fModule->validate_move_child(child->Parent()->PartitionData(),
|
||||
child->PartitionData(), start));
|
||||
}
|
||||
|
||||
// ValidateSetName
|
||||
//! Validates parameters for setting name of a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateSetName(KPartition *partition, char *name)
|
||||
{
|
||||
return (partition && name && partition->Parent()
|
||||
&& partition->ParentDiskSystem() == this && fModule
|
||||
&& fModule->validate_set_name
|
||||
&& fModule->validate_set_name(partition->PartitionData(), name));
|
||||
&& partition->ParentDiskSystem() == this && fModule
|
||||
&& fModule->validate_set_name
|
||||
&& fModule->validate_set_name(partition->PartitionData(), name));
|
||||
}
|
||||
|
||||
// ValidateSetContentName
|
||||
//! Validates parameters for setting name of the content of a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateSetContentName(KPartition *partition, char *name)
|
||||
{
|
||||
return (partition && name && partition->DiskSystem() == this
|
||||
&& fModule && fModule->validate_set_content_name
|
||||
&& fModule->validate_set_content_name(partition->PartitionData(),
|
||||
name));
|
||||
&& fModule && fModule->validate_set_content_name
|
||||
&& fModule->validate_set_content_name(partition->PartitionData(),
|
||||
name));
|
||||
}
|
||||
|
||||
// ValidateSetType
|
||||
//! Validates parameters for setting type of a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateSetType(KPartition *partition, const char *type)
|
||||
{
|
||||
return (partition && type && partition->ParentDiskSystem() == this
|
||||
&& fModule && fModule->validate_set_type
|
||||
&& fModule->validate_set_type(partition->PartitionData(), type));
|
||||
&& fModule && fModule->validate_set_type
|
||||
&& fModule->validate_set_type(partition->PartitionData(), type));
|
||||
}
|
||||
|
||||
// ValidateSetParameters
|
||||
//! Validates parameters for setting parameters of a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateSetParameters(KPartition *partition,
|
||||
const char *parameters)
|
||||
const char *parameters)
|
||||
{
|
||||
return (partition && partition->ParentDiskSystem() == this
|
||||
&& fModule && fModule->validate_set_parameters
|
||||
&& fModule->validate_set_parameters(partition->PartitionData(),
|
||||
parameters));
|
||||
&& fModule && fModule->validate_set_parameters
|
||||
&& fModule->validate_set_parameters(partition->PartitionData(),
|
||||
parameters));
|
||||
}
|
||||
|
||||
// ValidateSetContentParameters
|
||||
//! Validates parameters for setting parameters of the content of a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateSetContentParameters(KPartition *partition,
|
||||
const char *parameters)
|
||||
const char *parameters)
|
||||
{
|
||||
return (partition && partition->DiskSystem() == this && fModule
|
||||
&& fModule->validate_set_content_parameters
|
||||
@@ -379,33 +416,34 @@ KPartitioningSystem::ValidateSetContentParameters(KPartition *partition,
|
||||
}
|
||||
|
||||
// ValidateInitialize
|
||||
//! Validates parameters for initializing a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateInitialize(KPartition *partition, char *name,
|
||||
const char *parameters)
|
||||
const char *parameters)
|
||||
{
|
||||
return (partition && name && fModule && fModule->validate_initialize
|
||||
&& fModule->validate_initialize(partition->PartitionData(), name,
|
||||
parameters));
|
||||
&& fModule->validate_initialize(partition->PartitionData(), name,
|
||||
parameters));
|
||||
}
|
||||
|
||||
// ValidateCreateChild
|
||||
//! Validates parameters for creating child of a partition
|
||||
bool
|
||||
KPartitioningSystem::ValidateCreateChild(KPartition *partition, off_t *start,
|
||||
off_t *size, const char *type,
|
||||
const char *parameters, int32 *index)
|
||||
off_t *size, const char *type, const char *parameters, int32 *index)
|
||||
{
|
||||
int32 _index = 0;
|
||||
if (!index)
|
||||
index = &_index;
|
||||
return (partition && start && size && type
|
||||
&& partition->DiskSystem() == this && fModule
|
||||
&& fModule->validate_create_child
|
||||
&& fModule->validate_create_child(partition->PartitionData(),
|
||||
start, size, type, parameters,
|
||||
index));
|
||||
&& partition->DiskSystem() == this && fModule
|
||||
&& fModule->validate_create_child
|
||||
&& fModule->validate_create_child(partition->PartitionData(), start,
|
||||
size, type, parameters, index));
|
||||
}
|
||||
|
||||
// CountPartitionableSpaces
|
||||
//! Counts partitionable spaces on a partition
|
||||
int32
|
||||
KPartitioningSystem::CountPartitionableSpaces(KPartition *partition)
|
||||
{
|
||||
@@ -422,10 +460,10 @@ KPartitioningSystem::CountPartitionableSpaces(KPartition *partition)
|
||||
}
|
||||
|
||||
// GetPartitionableSpaces
|
||||
//! Retrieves a list of partitionable spaces on a partition
|
||||
status_t
|
||||
KPartitioningSystem::GetPartitionableSpaces(KPartition *partition,
|
||||
partitionable_space_data *buffer,
|
||||
int32 count, int32 *actualCount)
|
||||
partitionable_space_data *buffer, int32 count, int32 *actualCount)
|
||||
{
|
||||
if (!partition || partition->DiskSystem() != this || count > 0 && !buffer
|
||||
|| !actualCount || !fModule) {
|
||||
@@ -436,13 +474,14 @@ KPartitioningSystem::GetPartitionableSpaces(KPartition *partition,
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
return fModule->get_partitionable_spaces(partition->PartitionData(),
|
||||
buffer, count, actualCount);
|
||||
buffer, count, actualCount);
|
||||
}
|
||||
|
||||
// GetNextSupportedType
|
||||
//! Iterates through supported partition types
|
||||
status_t
|
||||
KPartitioningSystem::GetNextSupportedType(KPartition *partition, int32 *cookie,
|
||||
char *type)
|
||||
char *type)
|
||||
{
|
||||
if (!partition || partition->DiskSystem() != this || !cookie || !type
|
||||
|| !fModule) {
|
||||
@@ -455,6 +494,7 @@ KPartitioningSystem::GetNextSupportedType(KPartition *partition, int32 *cookie,
|
||||
}
|
||||
|
||||
// GetTypeForContentType
|
||||
//! Translates the "pretty" content type to an internal type
|
||||
status_t
|
||||
KPartitioningSystem::GetTypeForContentType(const char *contentType, char *type)
|
||||
{
|
||||
@@ -466,9 +506,10 @@ KPartitioningSystem::GetTypeForContentType(const char *contentType, char *type)
|
||||
}
|
||||
|
||||
// ShadowPartitionChanged
|
||||
//! Calls for additional modifications when shadow partition is changed
|
||||
status_t
|
||||
KPartitioningSystem::ShadowPartitionChanged(KPartition *partition,
|
||||
uint32 operation)
|
||||
uint32 operation)
|
||||
{
|
||||
if (!partition)
|
||||
return B_BAD_VALUE;
|
||||
@@ -482,6 +523,7 @@ KPartitioningSystem::ShadowPartitionChanged(KPartition *partition,
|
||||
}
|
||||
|
||||
// Repair
|
||||
//! Repairs a partition
|
||||
status_t
|
||||
KPartitioningSystem::Repair(KPartition *partition, bool checkOnly,
|
||||
KDiskDeviceJob *job)
|
||||
@@ -491,15 +533,17 @@ KPartitioningSystem::Repair(KPartition *partition, bool checkOnly,
|
||||
}
|
||||
|
||||
// Resize
|
||||
//! Resizes a partition
|
||||
status_t
|
||||
KPartitioningSystem::Resize(KPartition *partition, off_t size,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || size < 0)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->resize)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -516,23 +560,27 @@ KPartitioningSystem::Resize(KPartition *partition, off_t size,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->resize(fd, partition->ID(), size, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// ResizeChild
|
||||
//! Resizes child of a partition
|
||||
status_t
|
||||
KPartitioningSystem::ResizeChild(KPartition *child, off_t size,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!child || !job || !child->Parent() || size < 0)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->resize_child)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open (parent) partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(child->ID());
|
||||
@@ -550,23 +598,27 @@ KPartitioningSystem::ResizeChild(KPartition *child, off_t size,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->resize_child(fd, child->ID(), size, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Move
|
||||
//! Moves a partition
|
||||
status_t
|
||||
KPartitioningSystem::Move(KPartition *partition, off_t offset,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->move)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -583,23 +635,27 @@ KPartitioningSystem::Move(KPartition *partition, off_t offset,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->move(fd, partition->ID(), offset, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// MoveChild
|
||||
//! Moves child of a partition
|
||||
status_t
|
||||
KPartitioningSystem::MoveChild(KPartition *child, off_t offset,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!child || !job || !child->Parent())
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->move_child)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open (parent) partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(child->ID());
|
||||
@@ -617,23 +673,28 @@ KPartitioningSystem::MoveChild(KPartition *child, off_t offset,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->move_child(fd, child->Parent()->ID(), child->ID(), offset, job->ID());
|
||||
status_t result = fModule->move_child(fd, child->Parent()->ID(),
|
||||
child->ID(), offset, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// SetName
|
||||
//! Sets name of a partition
|
||||
status_t
|
||||
KPartitioningSystem::SetName(KPartition *partition, char *name,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !name)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->set_name)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -650,23 +711,27 @@ KPartitioningSystem::SetName(KPartition *partition, char *name,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->set_name(fd, partition->ID(), name, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// SetContentName
|
||||
//! Sets name of the content of a partition
|
||||
status_t
|
||||
KPartitioningSystem::SetContentName(KPartition *partition, char *name,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !name)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->set_content_name)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -683,23 +748,28 @@ KPartitioningSystem::SetContentName(KPartition *partition, char *name,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->set_content_name(fd, partition->ID(), name, job->ID());
|
||||
status_t result = fModule->set_content_name(fd, partition->ID(), name,
|
||||
job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// SetType
|
||||
//! Sets type of a partition
|
||||
status_t
|
||||
KPartitioningSystem::SetType(KPartition *partition, char *type,
|
||||
KDiskDeviceJob *job)
|
||||
KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !type)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->set_type)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -716,23 +786,27 @@ KPartitioningSystem::SetType(KPartition *partition, char *type,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->set_type(fd, partition->ID(), type, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// SetParameters
|
||||
//! Sets parameters of a partition
|
||||
status_t
|
||||
KPartitioningSystem::SetParameters(KPartition *partition,
|
||||
const char *parameters, KDiskDeviceJob *job)
|
||||
const char *parameters, KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !parameters)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->set_parameters)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -749,24 +823,28 @@ KPartitioningSystem::SetParameters(KPartition *partition,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->set_parameters(fd, partition->ID(), parameters, job->ID());
|
||||
status_t result = fModule->set_parameters(fd, partition->ID(), parameters,
|
||||
job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// SetContentParameters
|
||||
//! Sets parameters of the content of a partition
|
||||
status_t
|
||||
KPartitioningSystem::SetContentParameters(KPartition *partition,
|
||||
const char *parameters,
|
||||
KDiskDeviceJob *job)
|
||||
const char *parameters, KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !parameters)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->set_content_parameters)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -783,23 +861,28 @@ KPartitioningSystem::SetContentParameters(KPartition *partition,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->set_content_parameters(fd, partition->ID(), parameters, job->ID());
|
||||
status_t result = fModule->set_content_parameters(fd, partition->ID(),
|
||||
parameters, job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
//! Initializes a partition with this partitioning system
|
||||
status_t
|
||||
KPartitioningSystem::Initialize(KPartition *partition, const char *name,
|
||||
const char *parameters, KDiskDeviceJob *job)
|
||||
const char *parameters, KDiskDeviceJob *job)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !name /*|| !parameters*/)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->initialize)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -816,25 +899,29 @@ KPartitioningSystem::Initialize(KPartition *partition, const char *name,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->initialize(fd, partition->ID(), name, parameters, job->ID());
|
||||
status_t result = fModule->initialize(fd, partition->ID(), name, parameters,
|
||||
job->ID());
|
||||
|
||||
// cleanup and return
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
// CreateChild
|
||||
//! Creates a child partition
|
||||
status_t
|
||||
KPartitioningSystem::CreateChild(KPartition *partition, off_t offset,
|
||||
off_t size, const char *type,
|
||||
const char *parameters, KDiskDeviceJob *job,
|
||||
KPartition **child, partition_id childID)
|
||||
off_t size, const char *type, const char *parameters, KDiskDeviceJob *job,
|
||||
KPartition **child, partition_id childID)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !job || !type /*|| !parameters*/ || !child)
|
||||
return B_BAD_VALUE;
|
||||
if (!fModule->create_child)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
// lock partition and open partition device
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *_partition = manager->WriteLockPartition(partition->ID());
|
||||
@@ -851,9 +938,10 @@ KPartitioningSystem::CreateChild(KPartition *partition, off_t offset,
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
// let the module do its job
|
||||
status_t result = fModule->create_child(fd, partition->ID(), offset, size,
|
||||
type, parameters, job->ID(), &childID);
|
||||
type, parameters, job->ID(), &childID);
|
||||
|
||||
// find and return the child
|
||||
*child = manager->FindPartition(childID, false);
|
||||
@@ -864,6 +952,7 @@ KPartitioningSystem::CreateChild(KPartition *partition, off_t offset,
|
||||
}
|
||||
|
||||
// DeleteChild
|
||||
//! Deletes a child partition
|
||||
status_t
|
||||
KPartitioningSystem::DeleteChild(KPartition *child, KDiskDeviceJob *job)
|
||||
{
|
||||
@@ -889,4 +978,3 @@ KPartitioningSystem::UnloadModule()
|
||||
fModule = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user