_kern_supports_moving_partition() now returns the list of partitions that need to be unmounted for moving.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4040 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-07-21 14:17:03 +00:00
parent a94c3386de
commit c0b8ba64fd
2 changed files with 30 additions and 21 deletions

View File

@ -94,8 +94,9 @@ bool _kern_supports_resizing_partition(partition_id partitionID,
bool *canResizeContents,
bool *whileMounted);
bool _kern_supports_moving_partition(partition_id partitionID,
partition_id *buffer, size_t bufferSize,
bool *whileMounted);
partition_id *unmovable,
partition_id *needUnmounting,
size_t bufferSize);
bool _kern_supports_setting_partition_name(partition_id partitionID);
bool _kern_supports_setting_partition_content_name(partition_id partitionID,
bool *whileMounted);

View File

@ -32,26 +32,34 @@ check_shadow_partition(const KPartition *partition)
// get_unmovable_descendants
static
bool
get_unmovable_descendants(KPartition *partition, partition_id *&buffer,
size_t &bufferSize, bool &whileMounted)
get_unmovable_descendants(KPartition *partition, partition_id *&unmovable,
size_t &unmovableSize, partition_id *&needUnmounting,
size_t &needUnmountingSize)
{
// check parameters
if (!partition || !buffer || bufferSize == 0)
if (!partition || !unmovable || !needUnmounting || unmovableSize == 0
|| needUnmountingSize) {
return false;
}
// check partition
KDiskSystem *diskSystem = partition->DiskSystem();
if (!diskSystem || diskSystem->SupportsMoving(partition, &whileMounted)) {
buffer[0] = partition->ID();
bufferSize--;
bool isNoOp = true;
bool supports = (diskSystem
&& diskSystem->SupportsMoving(partition, &isNoOp));
if (supports) {
unmovable[0] = partition->ID();
unmovableSize--;
}
if (supports && !isNoOp && diskSystem->IsFileSystem()) {
needUnmounting[0] = partition->ID();
needUnmountingSize--;
}
// check child partitions
for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) {
bool whileChildMounted = false;
if (!get_unmovable_descendants(child, buffer, bufferSize,
whileChildMounted)) {
if (!get_unmovable_descendants(child, unmovable, unmovableSize,
needUnmounting, needUnmountingSize)) {
return false;
}
whileMounted &= whileChildMounted;
}
return true;
}
@ -377,14 +385,13 @@ _kern_supports_resizing_partition(partition_id partitionID,
// _kern_supports_moving_partition
bool
_kern_supports_moving_partition(partition_id partitionID, partition_id *buffer,
size_t bufferSize, bool *whileMounted)
_kern_supports_moving_partition(partition_id partitionID,
partition_id *unmovable,
partition_id *needUnmounting,
size_t bufferSize)
{
if (!buffer && bufferSize > 0)
if ((!unmovable || needUnmounting) && bufferSize > 0)
return false;
bool _whileMounted;
if (!whileMounted)
_whileMounted = &_whileMounted;
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
// get the partition
KPartition *partition = manager->ReadLockPartition(partitionID);
@ -403,9 +410,10 @@ _kern_supports_moving_partition(partition_id partitionID, partition_id *buffer,
if (!result)
return false;
// check the movability of the descendants' contents
*whileMounted = true;
if (!get_unmovable_descendants(partition, buffer, bufferSize,
*whileMounted)) {
size_t unmovableSize = bufferSize;
size_t needUnmountingSize = bufferSize;
if (!get_unmovable_descendants(partition, unmovable, unmovableSize,
needUnmounting, needUnmountingSize)) {
return false;
}
return result;