* Added a change counter parameter to all partition querying and
modification functions. Don't know why I didn't right from the start. * Implemented _kern_resize_partition(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4045 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f865306260
commit
5ee968b3df
@ -87,52 +87,72 @@ status_t _kern_get_next_disk_system_info(int32 *cookie,
|
||||
status_t _kern_find_disk_system(const char *name, user_disk_system_info *info);
|
||||
|
||||
bool _kern_supports_defragmenting_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_repairing_partition(partition_id partitionID,
|
||||
bool checkOnly, bool *whileMounted);
|
||||
int32 changeCounter, bool checkOnly,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_resizing_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
bool *canResizeContents,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_moving_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
partition_id *unmovable,
|
||||
partition_id *needUnmounting,
|
||||
size_t bufferSize);
|
||||
bool _kern_supports_setting_partition_name(partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_name(partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
bool _kern_supports_setting_partition_content_name(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_setting_partition_type(partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_parameters(partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_type(partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
bool _kern_supports_setting_partition_parameters(partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
bool _kern_supports_setting_partition_content_parameters(
|
||||
partition_id partitionID, bool *whileMounted);
|
||||
partition_id partitionID, int32 changeCounter, bool *whileMounted);
|
||||
bool _kern_supports_initializing_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *diskSystemName);
|
||||
bool _kern_supports_creating_child_partition(partition_id partitionID);
|
||||
bool _kern_supports_deleting_child_partition(partition_id partitionID);
|
||||
bool _kern_supports_creating_child_partition(partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
bool _kern_supports_deleting_child_partition(partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
bool _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
|
||||
status_t _kern_validate_resize_partition(partition_id partitionID,
|
||||
off_t *size, bool resizeContents);
|
||||
int32 changeCounter, off_t *size,
|
||||
bool resizeContents);
|
||||
status_t _kern_validate_move_partition(partition_id partitionID,
|
||||
off_t *newOffset, bool force);
|
||||
int32 changeCounter, off_t *newOffset,
|
||||
bool force);
|
||||
status_t _kern_validate_set_partition_name(partition_id partitionID,
|
||||
char *name);
|
||||
int32 changeCounter, char *name);
|
||||
status_t _kern_validate_set_partition_content_name(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
char *name);
|
||||
status_t _kern_validate_set_partition_type(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *type);
|
||||
status_t _kern_validate_initialize_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *diskSystemName,
|
||||
char *name,
|
||||
const char *parameters);
|
||||
status_t _kern_validate_create_child_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
off_t *offset, off_t *size,
|
||||
const char *type,
|
||||
const char *parameters);
|
||||
status_t _kern_get_partitionable_spaces(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
partitionable_space_data *buffer,
|
||||
int32 count, int32 *actualCount);
|
||||
status_t _kern_get_next_supported_partition_type(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
int32 *cookie, char *type);
|
||||
status_t _kern_get_partition_type_for_content_type(disk_system_id diskSystemID,
|
||||
const char *contentType,
|
||||
@ -146,27 +166,37 @@ status_t _kern_commit_disk_device_modifications(partition_id deviceID,
|
||||
status_t _kern_cancel_disk_device_modifications(partition_id deviceID);
|
||||
bool _kern_is_disk_device_modified(partition_id deviceID);
|
||||
|
||||
status_t _kern_defragment_partition(partition_id partition);
|
||||
status_t _kern_repair_partition(partition_id partition, bool checkOnly);
|
||||
status_t _kern_resize_partition(partition_id partition, off_t size,
|
||||
bool resizeContents);
|
||||
status_t _kern_move_partition(partition_id partition, off_t newOffset,
|
||||
bool force);
|
||||
status_t _kern_set_partition_name(partition_id partition, const char *name);
|
||||
status_t _kern_set_partition_content_name(partition_id partition,
|
||||
status_t _kern_defragment_partition(partition_id partitionID,
|
||||
int32 changeCounter);
|
||||
status_t _kern_repair_partition(partition_id partitionID, int32 changeCounter,
|
||||
bool checkOnly);
|
||||
status_t _kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t size, bool resizeContents);
|
||||
status_t _kern_move_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t newOffset, bool force);
|
||||
status_t _kern_set_partition_name(partition_id partitionID,
|
||||
int32 changeCounter, const char *name);
|
||||
status_t _kern_set_partition_content_name(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *name);
|
||||
status_t _kern_set_partition_type(partition_id partition, const char *type);
|
||||
status_t _kern_set_partition_parameters(partition_id partition,
|
||||
status_t _kern_set_partition_type(partition_id partitionID,
|
||||
int32 changeCounter, const char *type);
|
||||
status_t _kern_set_partition_parameters(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *parameters);
|
||||
status_t _kern_set_partition_content_parameters(partition_id partition,
|
||||
status_t _kern_set_partition_content_parameters(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *parameters);
|
||||
status_t _kern_initialize_partition(partition_id partition,
|
||||
status_t _kern_initialize_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *diskSystem, const char *name,
|
||||
const char *parameters);
|
||||
status_t _kern_create_child_partition(partition_id partition, off_t offset,
|
||||
off_t size, const char *type,
|
||||
const char *parameters, partition_id *child);
|
||||
status_t _kern_delete_partition(partition_id partition);
|
||||
status_t _kern_create_child_partition(partition_id partitionID,
|
||||
int32 changeCounter, off_t offset,
|
||||
off_t size, const char *type,
|
||||
const char *parameters,
|
||||
partition_id *child);
|
||||
status_t _kern_delete_partition(partition_id partitionID, int32 changeCounter);
|
||||
|
||||
#if 0
|
||||
|
||||
|
@ -23,10 +23,11 @@ get_current_team()
|
||||
// check_shadow_partition
|
||||
static
|
||||
bool
|
||||
check_shadow_partition(const KPartition *partition)
|
||||
check_shadow_partition(const KPartition *partition, int32 changeCounter)
|
||||
{
|
||||
return (partition && partition->Device() && partition->IsShadowPartition()
|
||||
&& partition->Device()->ShadowOwner() == get_current_team());
|
||||
&& partition->Device()->ShadowOwner() == get_current_team()
|
||||
&& changeCounter == partition->ChangeCounter());
|
||||
}
|
||||
|
||||
// get_unmovable_descendants
|
||||
@ -91,6 +92,43 @@ validate_move_descendants(KPartition *partition, off_t moveBy, bool force)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// validate_resize_partition
|
||||
static
|
||||
status_t
|
||||
validate_resize_partition(KPartition *partition, int32 changeCounter,
|
||||
off_t *size, bool resizeContents)
|
||||
{
|
||||
if (!partition || !size)
|
||||
return B_BAD_VALUE;
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return B_BUSY;
|
||||
}
|
||||
// get the parent disk system and let it check the value
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
if (!parentDiskSystem->ValidateResizeChild(partition, size))
|
||||
return B_ERROR;
|
||||
// get the child disk system and let it check the value
|
||||
if (resizeContents) {
|
||||
KDiskSystem *childDiskSystem = partition->DiskSystem();
|
||||
if (!childDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
off_t childSize = *size;
|
||||
// don't worry, if the content system desires to be smaller
|
||||
if (!childDiskSystem->ValidateResize(partition, &childSize)
|
||||
|| childSize > *size) {
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _kern_get_next_disk_device_id
|
||||
partition_id
|
||||
_kern_get_next_disk_device_id(int32 *cookie, size_t *neededSize)
|
||||
@ -199,7 +237,7 @@ _kern_get_disk_device_data(partition_id id, bool deviceOnly, bool shadow,
|
||||
|
||||
// _kern_get_partitionable_spaces
|
||||
status_t
|
||||
_kern_get_partitionable_spaces(partition_id partitionID,
|
||||
_kern_get_partitionable_spaces(partition_id partitionID, int32 changeCounter,
|
||||
partitionable_space_data *buffer,
|
||||
int32 count, int32 *actualCount)
|
||||
{
|
||||
@ -213,7 +251,7 @@ _kern_get_partitionable_spaces(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -305,7 +343,7 @@ _kern_find_disk_system(const char *name, user_disk_system_info *info)
|
||||
// _kern_supports_defragmenting_partition
|
||||
bool
|
||||
_kern_supports_defragmenting_partition(partition_id partitionID,
|
||||
bool *whileMounted)
|
||||
int32 changeCounter, bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -315,7 +353,9 @@ _kern_supports_defragmenting_partition(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -327,7 +367,8 @@ _kern_supports_defragmenting_partition(partition_id partitionID,
|
||||
|
||||
// _kern_supports_repairing_partition
|
||||
bool
|
||||
_kern_supports_repairing_partition(partition_id partitionID, bool checkOnly,
|
||||
_kern_supports_repairing_partition(partition_id partitionID,
|
||||
int32 changeCounter, bool checkOnly,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@ -338,7 +379,9 @@ _kern_supports_repairing_partition(partition_id partitionID, bool checkOnly,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -351,7 +394,7 @@ _kern_supports_repairing_partition(partition_id partitionID, bool checkOnly,
|
||||
// _kern_supports_resizing_partition
|
||||
bool
|
||||
_kern_supports_resizing_partition(partition_id partitionID,
|
||||
bool *canResizeContents,
|
||||
int32 changeCounter, bool *canResizeContents,
|
||||
bool *whileMounted)
|
||||
{
|
||||
if (!canResizeContents)
|
||||
@ -364,8 +407,14 @@ _kern_supports_resizing_partition(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return false;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return false;
|
||||
}
|
||||
// get the parent disk system
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
@ -385,7 +434,7 @@ _kern_supports_resizing_partition(partition_id partitionID,
|
||||
|
||||
// _kern_supports_moving_partition
|
||||
bool
|
||||
_kern_supports_moving_partition(partition_id partitionID,
|
||||
_kern_supports_moving_partition(partition_id partitionID, int32 changeCounter,
|
||||
partition_id *unmovable,
|
||||
partition_id *needUnmounting,
|
||||
size_t bufferSize)
|
||||
@ -400,8 +449,14 @@ _kern_supports_moving_partition(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return false;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return false;
|
||||
}
|
||||
// get the parent disk system
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
@ -421,7 +476,8 @@ _kern_supports_moving_partition(partition_id partitionID,
|
||||
|
||||
// _kern_supports_setting_partition_name
|
||||
bool
|
||||
_kern_supports_setting_partition_name(partition_id partitionID)
|
||||
_kern_supports_setting_partition_name(partition_id partitionID,
|
||||
int32 changeCounter)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -431,11 +487,15 @@ _kern_supports_setting_partition_name(partition_id partitionID)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return false;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return false;
|
||||
}
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
@ -446,6 +506,7 @@ _kern_supports_setting_partition_name(partition_id partitionID)
|
||||
// _kern_supports_setting_partition_content_name
|
||||
bool
|
||||
_kern_supports_setting_partition_content_name(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@ -456,7 +517,9 @@ _kern_supports_setting_partition_content_name(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -468,7 +531,8 @@ _kern_supports_setting_partition_content_name(partition_id partitionID,
|
||||
|
||||
// _kern_supports_setting_partition_type
|
||||
bool
|
||||
_kern_supports_setting_partition_type(partition_id partitionID)
|
||||
_kern_supports_setting_partition_type(partition_id partitionID,
|
||||
int32 changeCounter)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -478,11 +542,15 @@ _kern_supports_setting_partition_type(partition_id partitionID)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return false;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return false;
|
||||
}
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
@ -492,7 +560,8 @@ _kern_supports_setting_partition_type(partition_id partitionID)
|
||||
|
||||
// _kern_supports_setting_partition_parameters
|
||||
bool
|
||||
_kern_supports_setting_partition_parameters(partition_id partitionID)
|
||||
_kern_supports_setting_partition_parameters(partition_id partitionID,
|
||||
int32 changeCounter)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -502,11 +571,15 @@ _kern_supports_setting_partition_parameters(partition_id partitionID)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return false;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return false;
|
||||
}
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
@ -517,6 +590,7 @@ _kern_supports_setting_partition_parameters(partition_id partitionID)
|
||||
// _kern_supports_setting_partition_content_parameters
|
||||
bool
|
||||
_kern_supports_setting_partition_content_parameters(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@ -527,7 +601,9 @@ _kern_supports_setting_partition_content_parameters(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -541,6 +617,7 @@ _kern_supports_setting_partition_content_parameters(partition_id partitionID,
|
||||
// _kern_supports_initializing_partition
|
||||
bool
|
||||
_kern_supports_initializing_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *diskSystemName)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@ -551,7 +628,9 @@ _kern_supports_initializing_partition(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemName);
|
||||
@ -565,7 +644,8 @@ _kern_supports_initializing_partition(partition_id partitionID,
|
||||
|
||||
// _kern_supports_creating_child_partition
|
||||
bool
|
||||
_kern_supports_creating_child_partition(partition_id partitionID)
|
||||
_kern_supports_creating_child_partition(partition_id partitionID,
|
||||
int32 changeCounter)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -575,7 +655,9 @@ _kern_supports_creating_child_partition(partition_id partitionID)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -587,7 +669,8 @@ _kern_supports_creating_child_partition(partition_id partitionID)
|
||||
|
||||
// _kern_supports_deleting_child_partition
|
||||
bool
|
||||
_kern_supports_deleting_child_partition(partition_id partitionID)
|
||||
_kern_supports_deleting_child_partition(partition_id partitionID,
|
||||
int32 changeCounter)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -597,11 +680,15 @@ _kern_supports_deleting_child_partition(partition_id partitionID)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return false;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return false;
|
||||
}
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
@ -612,7 +699,7 @@ _kern_supports_deleting_child_partition(partition_id partitionID)
|
||||
// _kern_is_sub_disk_system_for
|
||||
bool
|
||||
_kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
partition_id partitionID, int32 changeCounter)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@ -622,7 +709,7 @@ _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -634,8 +721,8 @@ _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_validate_resize_partition
|
||||
status_t
|
||||
_kern_validate_resize_partition(partition_id partitionID, off_t *size,
|
||||
bool resizeContents)
|
||||
_kern_validate_resize_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t *size, bool resizeContents)
|
||||
{
|
||||
if (!size)
|
||||
return B_BAD_VALUE;
|
||||
@ -647,33 +734,14 @@ _kern_validate_resize_partition(partition_id partitionID, off_t *size,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
// get the parent disk system and let it check the value
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
status_t error = parentDiskSystem->ValidateResizeChild(partition, size);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
// get the child disk system and let it check the value
|
||||
if (resizeContents) {
|
||||
KDiskSystem *childDiskSystem = partition->DiskSystem();
|
||||
if (!childDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
off_t childSize = *size;
|
||||
error = childDiskSystem->ValidateResize(partition, &childSize);
|
||||
// don't worry, if the content system desires to be smaller
|
||||
if (error == B_OK && childSize > *size)
|
||||
error = B_ERROR;
|
||||
}
|
||||
return error;
|
||||
return validate_resize_partition(partition, changeCounter, size,
|
||||
resizeContents);
|
||||
}
|
||||
|
||||
// _kern_validate_move_partition
|
||||
status_t
|
||||
_kern_validate_move_partition(partition_id partitionID, off_t *newOffset,
|
||||
bool force)
|
||||
_kern_validate_move_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t *newOffset, bool force)
|
||||
{
|
||||
if (!newOffset)
|
||||
return B_BAD_VALUE;
|
||||
@ -685,24 +753,29 @@ _kern_validate_move_partition(partition_id partitionID, off_t *newOffset,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return B_BUSY;
|
||||
}
|
||||
// get the parent disk system and let it check the value
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
status_t error = parentDiskSystem->ValidateMoveChild(partition, newOffset);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (!parentDiskSystem->ValidateMoveChild(partition, newOffset))
|
||||
return B_ERROR;
|
||||
// let the concerned content disk systems check the value
|
||||
error = validate_move_descendants(partition,
|
||||
partition->Offset() - *newOffset, force);
|
||||
return error;
|
||||
return validate_move_descendants(partition,
|
||||
partition->Offset() - *newOffset, force);
|
||||
}
|
||||
|
||||
// _kern_validate_set_partition_name
|
||||
status_t
|
||||
_kern_validate_set_partition_name(partition_id partitionID, char *name)
|
||||
_kern_validate_set_partition_name(partition_id partitionID,
|
||||
int32 changeCounter, char *name)
|
||||
{
|
||||
if (!name)
|
||||
return B_BAD_VALUE;
|
||||
@ -714,8 +787,14 @@ _kern_validate_set_partition_name(partition_id partitionID, char *name)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return B_BUSY;
|
||||
}
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
@ -728,7 +807,8 @@ _kern_validate_set_partition_name(partition_id partitionID, char *name)
|
||||
|
||||
// _kern_validate_set_partition_content_name
|
||||
status_t
|
||||
_kern_validate_set_partition_content_name(partition_id partitionID, char *name)
|
||||
_kern_validate_set_partition_content_name(partition_id partitionID,
|
||||
int32 changeCounter, char *name)
|
||||
{
|
||||
if (!name)
|
||||
return B_BAD_VALUE;
|
||||
@ -740,8 +820,10 @@ _kern_validate_set_partition_content_name(partition_id partitionID, char *name)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return B_BAD_VALUE;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return B_BUSY;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem)
|
||||
@ -754,7 +836,8 @@ _kern_validate_set_partition_content_name(partition_id partitionID, char *name)
|
||||
|
||||
// _kern_validate_set_partition_type
|
||||
status_t
|
||||
_kern_validate_set_partition_type(partition_id partitionID, const char *type)
|
||||
_kern_validate_set_partition_type(partition_id partitionID,
|
||||
int32 changeCounter, const char *type)
|
||||
{
|
||||
if (!type)
|
||||
return B_BAD_VALUE;
|
||||
@ -766,8 +849,14 @@ _kern_validate_set_partition_type(partition_id partitionID, const char *type)
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
if (!check_shadow_partition(partition, changeCounter)
|
||||
|| !partition->Parent()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (partition->Parent()->IsBusy()
|
||||
|| partition->Parent()->IsDescendantBusy()) {
|
||||
return B_BUSY;
|
||||
}
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
@ -781,6 +870,7 @@ _kern_validate_set_partition_type(partition_id partitionID, const char *type)
|
||||
// _kern_validate_initialize_partition
|
||||
status_t
|
||||
_kern_validate_initialize_partition(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *diskSystemName, char *name,
|
||||
const char *parameters)
|
||||
{
|
||||
@ -794,20 +884,25 @@ _kern_validate_initialize_partition(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return B_BAD_VALUE;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return B_BUSY;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemName);
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
DiskSystemLoader loader(diskSystem, true);
|
||||
// get the info
|
||||
return diskSystem->ValidateInitialize(partition, name, parameters);
|
||||
if (diskSystem->ValidateInitialize(partition, name, parameters))
|
||||
return B_OK;
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// _kern_validate_create_child_partition
|
||||
status_t
|
||||
_kern_validate_create_child_partition(partition_id partitionID, off_t *offset,
|
||||
_kern_validate_create_child_partition(partition_id partitionID,
|
||||
int32 changeCounter, off_t *offset,
|
||||
off_t *size, const char *type,
|
||||
const char *parameters)
|
||||
{
|
||||
@ -821,8 +916,10 @@ _kern_validate_create_child_partition(partition_id partitionID, off_t *offset,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return B_BAD_VALUE;
|
||||
if (partition->IsBusy() || partition->IsDescendantBusy())
|
||||
return B_BUSY;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem)
|
||||
@ -838,7 +935,8 @@ _kern_validate_create_child_partition(partition_id partitionID, off_t *offset,
|
||||
// _kern_get_next_supported_partition_type
|
||||
status_t
|
||||
_kern_get_next_supported_partition_type(partition_id partitionID,
|
||||
int32 *cookie, char *type)
|
||||
int32 changeCounter, int32 *cookie,
|
||||
char *type)
|
||||
{
|
||||
if (!cookie || !type)
|
||||
return B_BAD_VALUE;
|
||||
@ -850,7 +948,7 @@ _kern_get_next_supported_partition_type(partition_id partitionID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition, changeCounter))
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
@ -936,7 +1034,7 @@ _kern_is_disk_device_modified(partition_id device)
|
||||
|
||||
// _kern_defragment_partition
|
||||
status_t
|
||||
_kern_defragment_partition(partition_id partition)
|
||||
_kern_defragment_partition(partition_id partitionID, int32 changeCounter)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -944,7 +1042,8 @@ _kern_defragment_partition(partition_id partition)
|
||||
|
||||
// _kern_repair_partition
|
||||
status_t
|
||||
_kern_repair_partition(partition_id partition, bool checkOnly)
|
||||
_kern_repair_partition(partition_id partitionID, int32 changeCounter,
|
||||
bool checkOnly)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -952,15 +1051,41 @@ _kern_repair_partition(partition_id partition, bool checkOnly)
|
||||
|
||||
// _kern_resize_partition
|
||||
status_t
|
||||
_kern_resize_partition(partition_id partition, off_t size, bool resizeContents)
|
||||
_kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t size, bool resizeContents)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->WriteLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceWriteLocker locker(partition->Device(), true);
|
||||
// check the size
|
||||
if (size == partition->Size())
|
||||
return B_OK;
|
||||
off_t proposedSize = size;
|
||||
status_t error = validate_resize_partition(partition, changeCounter,
|
||||
&proposedSize, resizeContents);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (proposedSize != size)
|
||||
return B_BAD_VALUE;
|
||||
// new size is fine -- resize the thing
|
||||
partition->SetSize(size);
|
||||
partition->Changed(B_PARTITION_CHANGED_SIZE);
|
||||
if (!resizeContents) {
|
||||
partition->UninitializeContents();
|
||||
partition->Changed(B_PARTITION_CHANGED_SIZE);
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _kern_move_partition
|
||||
status_t
|
||||
_kern_move_partition(partition_id partition, off_t newOffset, bool force)
|
||||
_kern_move_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t newOffset, bool force)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -968,7 +1093,8 @@ _kern_move_partition(partition_id partition, off_t newOffset, bool force)
|
||||
|
||||
// _kern_set_partition_name
|
||||
status_t
|
||||
_kern_set_partition_name(partition_id partition, const char *name)
|
||||
_kern_set_partition_name(partition_id partitionID, int32 changeCounter,
|
||||
const char *name)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -976,7 +1102,8 @@ _kern_set_partition_name(partition_id partition, const char *name)
|
||||
|
||||
// _kern_set_partition_content_name
|
||||
status_t
|
||||
_kern_set_partition_content_name(partition_id partition, const char *name)
|
||||
_kern_set_partition_content_name(partition_id partitionID, int32 changeCounter,
|
||||
const char *name)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -984,7 +1111,8 @@ _kern_set_partition_content_name(partition_id partition, const char *name)
|
||||
|
||||
// _kern_set_partition_type
|
||||
status_t
|
||||
_kern_set_partition_type(partition_id partition, const char *type)
|
||||
_kern_set_partition_type(partition_id partitionID, int32 changeCounter,
|
||||
const char *type)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -992,7 +1120,8 @@ _kern_set_partition_type(partition_id partition, const char *type)
|
||||
|
||||
// _kern_set_partition_parameters
|
||||
status_t
|
||||
_kern_set_partition_parameters(partition_id partition, const char *parameters)
|
||||
_kern_set_partition_parameters(partition_id partitionID, int32 changeCounter,
|
||||
const char *parameters)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -1000,7 +1129,8 @@ _kern_set_partition_parameters(partition_id partition, const char *parameters)
|
||||
|
||||
// _kern_set_partition_content_parameters
|
||||
status_t
|
||||
_kern_set_partition_content_parameters(partition_id partition,
|
||||
_kern_set_partition_content_parameters(partition_id partitionID,
|
||||
int32 changeCounter,
|
||||
const char *parameters)
|
||||
{
|
||||
// not implemented
|
||||
@ -1009,8 +1139,9 @@ _kern_set_partition_content_parameters(partition_id partition,
|
||||
|
||||
// _kern_initialize_partition
|
||||
status_t
|
||||
_kern_initialize_partition(partition_id partition, const char *diskSystem,
|
||||
const char *name, const char *parameters)
|
||||
_kern_initialize_partition(partition_id partitionID, int32 changeCounter,
|
||||
const char *diskSystem, const char *name,
|
||||
const char *parameters)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -1018,9 +1149,9 @@ _kern_initialize_partition(partition_id partition, const char *diskSystem,
|
||||
|
||||
// _kern_create_child_partition
|
||||
status_t
|
||||
_kern_create_child_partition(partition_id partition, off_t offset, off_t size,
|
||||
const char *type, const char *parameters,
|
||||
partition_id *child)
|
||||
_kern_create_child_partition(partition_id partitionID, int32 changeCounter,
|
||||
off_t offset, off_t size, const char *type,
|
||||
const char *parameters, partition_id *child)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
@ -1028,7 +1159,7 @@ _kern_create_child_partition(partition_id partition, off_t offset, off_t size,
|
||||
|
||||
// _kern_delete_partition
|
||||
status_t
|
||||
_kern_delete_partition(partition_id partition)
|
||||
_kern_delete_partition(partition_id partitionID, int32 changeCounter)
|
||||
{
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
|
Loading…
Reference in New Issue
Block a user