Removed the resizeContents/force from the resize/move syscalls. Fixed resize/move related bugs (partition was not check for status uninitialized).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4783 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -125,11 +125,9 @@ bool _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
|||||||
int32 changeCounter);
|
int32 changeCounter);
|
||||||
|
|
||||||
status_t _kern_validate_resize_partition(partition_id partitionID,
|
status_t _kern_validate_resize_partition(partition_id partitionID,
|
||||||
int32 changeCounter, off_t *size,
|
int32 changeCounter, off_t *size);
|
||||||
bool resizeContents);
|
|
||||||
status_t _kern_validate_move_partition(partition_id partitionID,
|
status_t _kern_validate_move_partition(partition_id partitionID,
|
||||||
int32 changeCounter, off_t *newOffset,
|
int32 changeCounter, off_t *newOffset);
|
||||||
bool force);
|
|
||||||
status_t _kern_validate_set_partition_name(partition_id partitionID,
|
status_t _kern_validate_set_partition_name(partition_id partitionID,
|
||||||
int32 changeCounter, char *name);
|
int32 changeCounter, char *name);
|
||||||
status_t _kern_validate_set_partition_content_name(partition_id partitionID,
|
status_t _kern_validate_set_partition_content_name(partition_id partitionID,
|
||||||
@@ -172,9 +170,9 @@ status_t _kern_defragment_partition(partition_id partitionID,
|
|||||||
status_t _kern_repair_partition(partition_id partitionID, int32 changeCounter,
|
status_t _kern_repair_partition(partition_id partitionID, int32 changeCounter,
|
||||||
bool checkOnly);
|
bool checkOnly);
|
||||||
status_t _kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
status_t _kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
||||||
off_t size, bool resizeContents);
|
off_t size);
|
||||||
status_t _kern_move_partition(partition_id partitionID, int32 changeCounter,
|
status_t _kern_move_partition(partition_id partitionID, int32 changeCounter,
|
||||||
off_t newOffset, bool force);
|
off_t newOffset);
|
||||||
status_t _kern_set_partition_name(partition_id partitionID,
|
status_t _kern_set_partition_name(partition_id partitionID,
|
||||||
int32 changeCounter, const char *name);
|
int32 changeCounter, const char *name);
|
||||||
status_t _kern_set_partition_content_name(partition_id partitionID,
|
status_t _kern_set_partition_content_name(partition_id partitionID,
|
||||||
|
|||||||
@@ -72,16 +72,20 @@ get_unmovable_descendants(KPartition *partition, partition_id *&unmovable,
|
|||||||
// validate_move_descendants
|
// validate_move_descendants
|
||||||
static
|
static
|
||||||
status_t
|
status_t
|
||||||
validate_move_descendants(KPartition *partition, off_t moveBy, bool force,
|
validate_move_descendants(KPartition *partition, off_t moveBy,
|
||||||
bool markMovable = false)
|
bool markMovable = false)
|
||||||
{
|
{
|
||||||
if (!partition)
|
if (!partition)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
// check partition
|
// check partition
|
||||||
|
bool uninitialized = partition->IsUninitialized();
|
||||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||||
bool movable = (diskSystem || diskSystem->SupportsMoving(partition, NULL));
|
bool movable = (uninitialized || diskSystem
|
||||||
|
|| diskSystem->SupportsMoving(partition, NULL));
|
||||||
if (markMovable)
|
if (markMovable)
|
||||||
partition->SetAlgorithmData(movable);
|
partition->SetAlgorithmData(movable);
|
||||||
|
// moving partition is supported in principle, now check the new offset
|
||||||
|
if (!uninitialized) {
|
||||||
if (movable) {
|
if (movable) {
|
||||||
off_t offset = partition->Offset() + moveBy;
|
off_t offset = partition->Offset() + moveBy;
|
||||||
off_t newOffset = offset;
|
off_t newOffset = offset;
|
||||||
@@ -89,14 +93,15 @@ validate_move_descendants(KPartition *partition, off_t moveBy, bool force,
|
|||||||
|| newOffset != offset) {
|
|| newOffset != offset) {
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
} else if (!force)
|
} else
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
// check children
|
// check children
|
||||||
for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) {
|
for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) {
|
||||||
status_t error = validate_move_descendants(child, moveBy, force);
|
status_t error = validate_move_descendants(child, moveBy);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +147,7 @@ validate_repair_partition(KPartition *partition, int32 changeCounter,
|
|||||||
static
|
static
|
||||||
status_t
|
status_t
|
||||||
validate_resize_partition(KPartition *partition, int32 changeCounter,
|
validate_resize_partition(KPartition *partition, int32 changeCounter,
|
||||||
off_t *size, bool resizeContents)
|
off_t *size)
|
||||||
{
|
{
|
||||||
if (!partition || !size
|
if (!partition || !size
|
||||||
|| !check_shadow_partition(partition, changeCounter)
|
|| !check_shadow_partition(partition, changeCounter)
|
||||||
@@ -159,8 +164,11 @@ validate_resize_partition(KPartition *partition, int32 changeCounter,
|
|||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
if (!parentDiskSystem->ValidateResizeChild(partition, size))
|
if (!parentDiskSystem->ValidateResizeChild(partition, size))
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
// if contents is uninitialized, then there's no need to check anything
|
||||||
|
// more
|
||||||
|
if (partition->IsUninitialized())
|
||||||
|
return B_OK;
|
||||||
// get the child disk system and let it check the value
|
// get the child disk system and let it check the value
|
||||||
if (resizeContents) {
|
|
||||||
KDiskSystem *childDiskSystem = partition->DiskSystem();
|
KDiskSystem *childDiskSystem = partition->DiskSystem();
|
||||||
if (!childDiskSystem)
|
if (!childDiskSystem)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
@@ -170,14 +178,13 @@ validate_resize_partition(KPartition *partition, int32 changeCounter,
|
|||||||
|| childSize > *size) {
|
|| childSize > *size) {
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate_move_partition
|
// validate_move_partition
|
||||||
status_t
|
status_t
|
||||||
validate_move_partition(KPartition *partition, int32 changeCounter,
|
validate_move_partition(KPartition *partition, int32 changeCounter,
|
||||||
off_t *newOffset, bool force, bool markMovable = false)
|
off_t *newOffset, bool markMovable = false)
|
||||||
{
|
{
|
||||||
if (!partition || !newOffset
|
if (!partition || !newOffset
|
||||||
|| !check_shadow_partition(partition, changeCounter)
|
|| !check_shadow_partition(partition, changeCounter)
|
||||||
@@ -196,7 +203,7 @@ validate_move_partition(KPartition *partition, int32 changeCounter,
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
// let the concerned content disk systems check the value
|
// let the concerned content disk systems check the value
|
||||||
return validate_move_descendants(partition,
|
return validate_move_descendants(partition,
|
||||||
partition->Offset() - *newOffset, force, markMovable);
|
partition->Offset() - *newOffset, markMovable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move_descendants
|
// move_descendants
|
||||||
@@ -1012,7 +1019,7 @@ _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
|||||||
// _kern_validate_resize_partition
|
// _kern_validate_resize_partition
|
||||||
status_t
|
status_t
|
||||||
_kern_validate_resize_partition(partition_id partitionID, int32 changeCounter,
|
_kern_validate_resize_partition(partition_id partitionID, int32 changeCounter,
|
||||||
off_t *size, bool resizeContents)
|
off_t *size)
|
||||||
{
|
{
|
||||||
if (!size)
|
if (!size)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1024,14 +1031,13 @@ _kern_validate_resize_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
PartitionRegistrar registrar1(partition, true);
|
PartitionRegistrar registrar1(partition, true);
|
||||||
PartitionRegistrar registrar2(partition->Device(), true);
|
PartitionRegistrar registrar2(partition->Device(), true);
|
||||||
DeviceReadLocker locker(partition->Device(), true);
|
DeviceReadLocker locker(partition->Device(), true);
|
||||||
return validate_resize_partition(partition, changeCounter, size,
|
return validate_resize_partition(partition, changeCounter, size);
|
||||||
resizeContents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _kern_validate_move_partition
|
// _kern_validate_move_partition
|
||||||
status_t
|
status_t
|
||||||
_kern_validate_move_partition(partition_id partitionID, int32 changeCounter,
|
_kern_validate_move_partition(partition_id partitionID, int32 changeCounter,
|
||||||
off_t *newOffset, bool force)
|
off_t *newOffset)
|
||||||
{
|
{
|
||||||
if (!newOffset)
|
if (!newOffset)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1043,8 +1049,7 @@ _kern_validate_move_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
PartitionRegistrar registrar1(partition, true);
|
PartitionRegistrar registrar1(partition, true);
|
||||||
PartitionRegistrar registrar2(partition->Device(), true);
|
PartitionRegistrar registrar2(partition->Device(), true);
|
||||||
DeviceReadLocker locker(partition->Device(), true);
|
DeviceReadLocker locker(partition->Device(), true);
|
||||||
return validate_resize_partition(partition, changeCounter, newOffset,
|
return validate_move_partition(partition, changeCounter, newOffset);
|
||||||
force);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _kern_validate_set_partition_name
|
// _kern_validate_set_partition_name
|
||||||
@@ -1329,7 +1334,7 @@ _kern_repair_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
// _kern_resize_partition
|
// _kern_resize_partition
|
||||||
status_t
|
status_t
|
||||||
_kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
_kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
||||||
off_t size, bool resizeContents)
|
off_t size)
|
||||||
{
|
{
|
||||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||||
// get the partition
|
// get the partition
|
||||||
@@ -1344,7 +1349,7 @@ _kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
off_t proposedSize = size;
|
off_t proposedSize = size;
|
||||||
status_t error = validate_resize_partition(partition, changeCounter,
|
status_t error = validate_resize_partition(partition, changeCounter,
|
||||||
&proposedSize, resizeContents);
|
&proposedSize);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
if (proposedSize != size)
|
if (proposedSize != size)
|
||||||
@@ -1357,12 +1362,10 @@ _kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
partition, B_PARTITION_RESIZE_CHILD);
|
partition, B_PARTITION_RESIZE_CHILD);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
if (resizeContents) {
|
|
||||||
// implicit content disk system changes
|
// implicit content disk system changes
|
||||||
|
if (partition->DiskSystem()) {
|
||||||
error = partition->DiskSystem()->ShadowPartitionChanged(
|
error = partition->DiskSystem()->ShadowPartitionChanged(
|
||||||
partition, B_PARTITION_RESIZE);
|
partition, B_PARTITION_RESIZE);
|
||||||
} else {
|
|
||||||
partition->UninitializeContents();
|
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -1370,7 +1373,7 @@ _kern_resize_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
// _kern_move_partition
|
// _kern_move_partition
|
||||||
status_t
|
status_t
|
||||||
_kern_move_partition(partition_id partitionID, int32 changeCounter,
|
_kern_move_partition(partition_id partitionID, int32 changeCounter,
|
||||||
off_t newOffset, bool force)
|
off_t newOffset)
|
||||||
{
|
{
|
||||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||||
// get the partition
|
// get the partition
|
||||||
@@ -1385,7 +1388,7 @@ _kern_move_partition(partition_id partitionID, int32 changeCounter,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
off_t proposedOffset = newOffset;
|
off_t proposedOffset = newOffset;
|
||||||
status_t error = validate_move_partition(partition, changeCounter,
|
status_t error = validate_move_partition(partition, changeCounter,
|
||||||
&proposedOffset, force, true);
|
&proposedOffset, true);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
if (proposedOffset != newOffset)
|
if (proposedOffset != newOffset)
|
||||||
|
|||||||
Reference in New Issue
Block a user