Loading fastboot/device/commands.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args) {FB_VAR_HAS_SLOT, {GetHasSlot, GetAllPartitionArgsNoSlot}}, {FB_VAR_SLOT_SUCCESSFUL, {GetSlotSuccessful, nullptr}}, {FB_VAR_SLOT_UNBOOTABLE, {GetSlotUnbootable, nullptr}}, {FB_VAR_PARTITION_SIZE, {GetPartitionSize, GetAllPartitionArgsWithSlot}}, {FB_VAR_PARTITION_SIZE, {::GetPartitionSize, GetAllPartitionArgsWithSlot}}, {FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}}, {FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}}, {FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}}, Loading fs_mgr/liblp/builder_test.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,13 @@ TEST_F(BuilderTest, ResizePartition) { EXPECT_EQ(extent->num_sectors(), 32768 / LP_SECTOR_SIZE); EXPECT_EQ(extent->physical_sector(), 32); auto exported = builder->Export(); ASSERT_NE(exported, nullptr); ASSERT_EQ(FindPartition(*exported.get(), "not found"), nullptr); auto entry = FindPartition(*exported.get(), "system"); ASSERT_NE(entry, nullptr); ASSERT_EQ(GetPartitionSize(*exported.get(), *entry), 32768); // Test shrinking to 0. builder->ResizePartition(system, 0); EXPECT_EQ(system->size(), 0); Loading fs_mgr/liblp/include/liblp/liblp.h +4 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,10 @@ uint32_t SlotNumberForSlotSuffix(const std::string& suffix); std::string SlotSuffixForSlotNumber(uint32_t slot_number); std::string GetPartitionSlotSuffix(const std::string& partition_name); // Helpers for common functions. const LpMetadataPartition* FindPartition(const LpMetadata& metadata, const std::string& name); uint64_t GetPartitionSize(const LpMetadata& metadata, const LpMetadataPartition& partition); } // namespace fs_mgr } // namespace android Loading fs_mgr/liblp/utility.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,24 @@ std::vector<std::string> GetBlockDevicePartitionNames(const LpMetadata& metadata return list; } const LpMetadataPartition* FindPartition(const LpMetadata& metadata, const std::string& name) { for (const auto& partition : metadata.partitions) { if (GetPartitionName(partition) == name) { return &partition; } } return nullptr; } uint64_t GetPartitionSize(const LpMetadata& metadata, const LpMetadataPartition& partition) { uint64_t total_size = 0; for (uint32_t i = 0; i < partition.num_extents; i++) { const auto& extent = metadata.extents[partition.first_extent_index + i]; total_size += extent.num_sectors * LP_SECTOR_SIZE; } return total_size; } std::string GetPartitionSlotSuffix(const std::string& partition_name) { if (partition_name.size() <= 2) { return ""; Loading Loading
fastboot/device/commands.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args) {FB_VAR_HAS_SLOT, {GetHasSlot, GetAllPartitionArgsNoSlot}}, {FB_VAR_SLOT_SUCCESSFUL, {GetSlotSuccessful, nullptr}}, {FB_VAR_SLOT_UNBOOTABLE, {GetSlotUnbootable, nullptr}}, {FB_VAR_PARTITION_SIZE, {GetPartitionSize, GetAllPartitionArgsWithSlot}}, {FB_VAR_PARTITION_SIZE, {::GetPartitionSize, GetAllPartitionArgsWithSlot}}, {FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}}, {FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}}, {FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}}, Loading
fs_mgr/liblp/builder_test.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,13 @@ TEST_F(BuilderTest, ResizePartition) { EXPECT_EQ(extent->num_sectors(), 32768 / LP_SECTOR_SIZE); EXPECT_EQ(extent->physical_sector(), 32); auto exported = builder->Export(); ASSERT_NE(exported, nullptr); ASSERT_EQ(FindPartition(*exported.get(), "not found"), nullptr); auto entry = FindPartition(*exported.get(), "system"); ASSERT_NE(entry, nullptr); ASSERT_EQ(GetPartitionSize(*exported.get(), *entry), 32768); // Test shrinking to 0. builder->ResizePartition(system, 0); EXPECT_EQ(system->size(), 0); Loading
fs_mgr/liblp/include/liblp/liblp.h +4 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,10 @@ uint32_t SlotNumberForSlotSuffix(const std::string& suffix); std::string SlotSuffixForSlotNumber(uint32_t slot_number); std::string GetPartitionSlotSuffix(const std::string& partition_name); // Helpers for common functions. const LpMetadataPartition* FindPartition(const LpMetadata& metadata, const std::string& name); uint64_t GetPartitionSize(const LpMetadata& metadata, const LpMetadataPartition& partition); } // namespace fs_mgr } // namespace android Loading
fs_mgr/liblp/utility.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,24 @@ std::vector<std::string> GetBlockDevicePartitionNames(const LpMetadata& metadata return list; } const LpMetadataPartition* FindPartition(const LpMetadata& metadata, const std::string& name) { for (const auto& partition : metadata.partitions) { if (GetPartitionName(partition) == name) { return &partition; } } return nullptr; } uint64_t GetPartitionSize(const LpMetadata& metadata, const LpMetadataPartition& partition) { uint64_t total_size = 0; for (uint32_t i = 0; i < partition.num_extents; i++) { const auto& extent = metadata.extents[partition.first_extent_index + i]; total_size += extent.num_sectors * LP_SECTOR_SIZE; } return total_size; } std::string GetPartitionSlotSuffix(const std::string& partition_name) { if (partition_name.size() <= 2) { return ""; Loading