diff --git a/headers/private/storage/Partition.h b/headers/private/storage/Partition.h index 5c55d06fb9..b6f1f0b3fe 100644 --- a/headers/private/storage/Partition.h +++ b/headers/private/storage/Partition.h @@ -26,6 +26,7 @@ public: off_t Offset() const; // 0 for devices off_t Size() const; + off_t ContentSize() const; // 0 if uninitialized uint32 BlockSize() const; int32 Index() const; // 0 for devices uint32 Status() const; @@ -76,12 +77,13 @@ public: bool CanRepair(bool checkOnly, bool *whileMounted = NULL) const; status_t Repair(bool checkOnly) const; - bool CanResize(bool *canResizeContents, bool *whileMounted = NULL) const; + bool CanResize(bool *canResizeContents = NULL, + bool *whileMounted = NULL) const; status_t ValidateResize(off_t *size, bool resizeContents = true) const; status_t Resize(off_t size, bool resizeContents = true); - bool CanMove(BObjectList *unmovableDescendants, - BObjectList *movableOnlyIfUnmounted) const; + bool CanMove(BObjectList *unmovableDescendants = NULL, + BObjectList *movableOnlyIfUnmounted = NULL) const; status_t ValidateMove(off_t *newOffset, bool force = false) const; status_t Move(off_t newOffset, bool force = false); diff --git a/src/kits/storage/Partition.cpp b/src/kits/storage/Partition.cpp index 6a97a8ae2a..0ccdda8299 100644 --- a/src/kits/storage/Partition.cpp +++ b/src/kits/storage/Partition.cpp @@ -92,6 +92,13 @@ BPartition::Size() const return (fPartitionData ? fPartitionData->size : 0); } +// ContentSize +off_t +BPartition::ContentSize() const +{ + return (fPartitionData ? fPartitionData->content_size : 0); +} + // BlockSize /*! \brief Returns the block size of the device. \return The block size of the device in bytes. @@ -513,10 +520,8 @@ BPartition::CanMove(BObjectList *unmovableDescendants, BObjectList *movableOnlyIfUnmounted) const { // check parameters - if (!unmovableDescendants || !movableOnlyIfUnmounted || !fPartitionData - || IsDevice() || !Parent() || !_IsShadow()) { + if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow()) return false; - } // count descendants and allocate partition_id arrays large enough int32 descendantCount = _CountDescendants(); partition_id *unmovableIDs = NULL; @@ -542,18 +547,24 @@ BPartition::CanMove(BObjectList *unmovableDescendants, _ChangeCounter(), unmovableIDs, needUnmountingIDs, descendantCount); if (result) { - // find unmovable BPartition objects for returned IDs - for (int32 i = 0; i < descendantCount && unmovableIDs[i] != -1; i++) { - BPartition *descendant = FindDescendant(unmovableIDs[i]); - if (!descendant || !unmovableDescendants->AddItem(descendant)) - return false; + // get unmovable BPartition objects for returned IDs + if (unmovableDescendants) { + for (int32 i = 0; i < descendantCount && unmovableIDs[i] != -1; + i++) { + BPartition *descendant = FindDescendant(unmovableIDs[i]); + if (!descendant || !unmovableDescendants->AddItem(descendant)) + return false; + } } - // find BPartition objects needing to be unmounted for returned IDs - for (int32 i = 0; i < descendantCount && needUnmountingIDs[i] != -1; - i++) { - BPartition *descendant = FindDescendant(needUnmountingIDs[i]); - if (!descendant || !movableOnlyIfUnmounted->AddItem(descendant)) - return false; + // get BPartition objects needing to be unmounted for returned IDs + if (movableOnlyIfUnmounted) { + for (int32 i = 0; + i < descendantCount && needUnmountingIDs[i] != -1; + i++) { + BPartition *descendant = FindDescendant(needUnmountingIDs[i]); + if (!descendant || !movableOnlyIfUnmounted->AddItem(descendant)) + return false; + } } } return result;