Parse Android boot.img.
The Android boot.img contains kernel, ramdisk and optionally second
stage bootloader. Both kernel and ramdisk could be compressed by gzip.
This patch add a new boot img filesystem to parse boot.img to split
it into |File|s, and find the deflates to utilize puffin, which could
save us several MBs in delta payload size.
As a side effect, generating delta payload for boot partition is much
faster because it is now splitted into smaller files, and we can make
use of multithreading.
Bug: 110494725
Test: generate a delta payload
Change-Id: If41468b37a407fe1b7a70c2b61f632f7df8176d5
diff --git a/payload_generator/squashfs_filesystem.cc b/payload_generator/squashfs_filesystem.cc
index c98ad12..6c892f5 100644
--- a/payload_generator/squashfs_filesystem.cc
+++ b/payload_generator/squashfs_filesystem.cc
@@ -44,14 +44,6 @@
namespace {
-Extent ExtentForBytes(uint64_t block_size,
- uint64_t start_bytes,
- uint64_t size_bytes) {
- uint64_t start_block = start_bytes / block_size;
- uint64_t end_block = (start_bytes + size_bytes + block_size - 1) / block_size;
- return ExtentForRange(start_block, end_block - start_block);
-}
-
// The size of the squashfs super block.
constexpr size_t kSquashfsSuperBlockSize = 96;
constexpr uint64_t kSquashfsCompressedBit = 1 << 24;
@@ -192,8 +184,7 @@
for (const auto& file : files_) {
file_extents.AddExtents(file.extents);
}
- vector<Extent> full = {
- ExtentForRange(0, (size_ + kBlockSize - 1) / kBlockSize)};
+ vector<Extent> full = {ExtentForBytes(kBlockSize, 0, size_)};
auto metadata_extents = FilterExtentRanges(full, file_extents);
// For now there should be at most two extents. One for superblock and one for
// metadata at the end. Just create appropriate files with <metadata-i> name.