diff options
author | Amin Hassani <ahassani@google.com> | 2017-12-06 13:47:52 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-12-12 13:50:58 -0800 |
commit | d8b67f49d7f8ae291cd4fa901b2d3767137704e7 (patch) | |
tree | 2d039015afcd03433da0dd8860a83ce3ce2a65cf /payload_generator/deflate_utils.cc | |
parent | 06c6d088b89656a120d40c4b578200c87af5c4c8 (diff) |
update_engine: Remove the duplicate BlocksInExtents
This patch removes the duplicate BlocksInExtents from extent_utils.h and fixes
the remainder of the code to reflect this change.
BUG=none
TEST=unittests pass;
Change-Id: I76f5106f75072b20cd8f41f081b2f2b07aeac9a8
Reviewed-on: https://chromium-review.googlesource.com/812009
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Alex Deymo <deymo@google.com>
Reviewed-by: Sen Jiang <senj@chromium.org>
Diffstat (limited to 'payload_generator/deflate_utils.cc')
-rw-r--r-- | payload_generator/deflate_utils.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/payload_generator/deflate_utils.cc b/payload_generator/deflate_utils.cc index 7a5d9a42..88e42e0d 100644 --- a/payload_generator/deflate_utils.cc +++ b/payload_generator/deflate_utils.cc @@ -49,7 +49,7 @@ bool CopyExtentsToFile(const string& in_path, const vector<Extent> extents, const string& out_path, size_t block_size) { - brillo::Blob data(BlocksInExtents(extents) * block_size); + brillo::Blob data(utils::BlocksInExtents(extents) * block_size); TEST_AND_RETURN_FALSE( utils::ReadExtents(in_path, extents, &data, data.size(), block_size)); TEST_AND_RETURN_FALSE( @@ -61,7 +61,8 @@ bool IsSquashfsImage(const string& part_path, const FilesystemInterface::File& file) { // Only check for files with img postfix. if (base::EndsWith(file.name, ".img", base::CompareCase::SENSITIVE) && - BlocksInExtents(file.extents) >= kMinimumSquashfsImageSize / kBlockSize) { + utils::BlocksInExtents(file.extents) >= + kMinimumSquashfsImageSize / kBlockSize) { brillo::Blob super_block; TEST_AND_RETURN_FALSE( utils::ReadFileChunk(part_path, @@ -87,11 +88,11 @@ bool RealignSplittedFiles(const FilesystemInterface::File& file, ShiftBitExtentsOverExtents(file.extents, &in_file.deflates)); in_file.name = file.name + "/" + in_file.name; - num_blocks += BlocksInExtents(in_file.extents); + num_blocks += utils::BlocksInExtents(in_file.extents); } // Check that all files in |in_files| cover the entire image. - TEST_AND_RETURN_FALSE(BlocksInExtents(file.extents) == num_blocks); + TEST_AND_RETURN_FALSE(utils::BlocksInExtents(file.extents) == num_blocks); return true; } @@ -111,7 +112,8 @@ ByteExtent ExpandToByteExtent(const BitExtent& extent) { bool ShiftExtentsOverExtents(const vector<Extent>& base_extents, vector<Extent>* over_extents) { - if (BlocksInExtents(base_extents) < BlocksInExtents(*over_extents)) { + if (utils::BlocksInExtents(base_extents) < + utils::BlocksInExtents(*over_extents)) { LOG(ERROR) << "over_extents have more blocks than base_extents! Invalid!"; return false; } @@ -160,7 +162,7 @@ bool ShiftBitExtentsOverExtents(const vector<Extent>& base_extents, // does not exceed |base_extents|. auto last_extent = ExpandToByteExtent(over_extents->back()); TEST_AND_RETURN_FALSE(last_extent.offset + last_extent.length <= - BlocksInExtents(base_extents) * kBlockSize); + utils::BlocksInExtents(base_extents) * kBlockSize); for (auto o_ext = over_extents->begin(); o_ext != over_extents->end();) { size_t gap_blocks = base_extents[0].start_block(); |