diff options
author | Amin Hassani <ahassani@chromium.org> | 2020-02-26 14:47:23 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-28 09:19:39 +0000 |
commit | 1a200c114fd51a62b1be3269bcd43fefcae3e20c (patch) | |
tree | b9716df5cb4b8858a018f1b2a30f4af36e1a9f24 | |
parent | 5e9cd71ea8f964c71de657d0a14a2bd0dcc5af75 (diff) |
update_engine: Don't search for deflates again in SquashFS compressed files
When we initialize a SquashFS file system, at the same time we find the
location of all deflate buffers. But for some files that have specific
postfix like gz or zip, we try to find the deflates there again. But, we
should only do this when the SquashFS did not actually compress that
file. Otherwise we're just gonna fail.
BUG=chromium:1050869
TEST=cros_generate_update_payload --image gs://chromeos-releases/dev-channel/eve-kvm/12871.1.0/dlc/pita/package/dlc.img --src_image gs://chromeos-releases/dev-channel/eve-kvm/12861.0.0/dlc/pita/package/dlc.img --output delta.bin --debug --work_dir workdir
TEST=sudo FEATURES=test emerge update_engine
Change-Id: I8b01fb182b88d7ec75dcbfa4c1271caf3bf074fe
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2076162
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
-rw-r--r-- | payload_generator/deflate_utils.cc | 2 | ||||
-rw-r--r-- | payload_generator/filesystem_interface.h | 7 | ||||
-rw-r--r-- | payload_generator/squashfs_filesystem.cc | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/payload_generator/deflate_utils.cc b/payload_generator/deflate_utils.cc index ef8d257d..8db67ce0 100644 --- a/payload_generator/deflate_utils.cc +++ b/payload_generator/deflate_utils.cc @@ -296,7 +296,7 @@ bool PreprocessPartitionFiles(const PartitionConfig& part, } } - if (extract_deflates) { + if (extract_deflates && !file.is_compressed) { // Search for deflates if the file is in zip or gzip format. // .zvoice files may eventually move out of rootfs. If that happens, // remove ".zvoice" (crbug.com/782918). diff --git a/payload_generator/filesystem_interface.h b/payload_generator/filesystem_interface.h index d04295cd..05d387f6 100644 --- a/payload_generator/filesystem_interface.h +++ b/payload_generator/filesystem_interface.h @@ -62,6 +62,13 @@ class FilesystemInterface { // indicating the starting block, and the number of consecutive blocks. std::vector<Extent> extents; + // If true, the file is already compressed on the disk, so we don't need to + // parse it again for deflates. For example, image .gz files inside a + // compressed SquashFS image. They might have already been compressed by the + // mksquashfs, so we can't really parse the file and look for deflate + // compressed parts anymore. + bool is_compressed = false; + // All the deflate locations in the file. These locations are not relative // to the extents. They are relative to the file system itself. std::vector<puffin::BitExtent> deflates; diff --git a/payload_generator/squashfs_filesystem.cc b/payload_generator/squashfs_filesystem.cc index 98387949..234a5878 100644 --- a/payload_generator/squashfs_filesystem.cc +++ b/payload_generator/squashfs_filesystem.cc @@ -166,6 +166,7 @@ bool SquashfsFilesystem::Init(const string& map, uint64_t start; TEST_AND_RETURN_FALSE(base::StringToUint64(splits[1], &start)); uint64_t cur_offset = start; + bool is_compressed = false; for (size_t i = 2; i < splits.size(); ++i) { uint64_t blk_size; TEST_AND_RETURN_FALSE(base::StringToUint64(splits[i], &blk_size)); @@ -173,10 +174,11 @@ bool SquashfsFilesystem::Init(const string& map, auto new_blk_size = blk_size & ~kSquashfsCompressedBit; TEST_AND_RETURN_FALSE(new_blk_size <= header.block_size); if (new_blk_size > 0 && !(blk_size & kSquashfsCompressedBit)) { - // Compressed block + // It is a compressed block. if (is_zlib && extract_deflates) { zlib_blks.emplace_back(cur_offset, new_blk_size); } + is_compressed = true; } cur_offset += new_blk_size; } @@ -186,6 +188,7 @@ bool SquashfsFilesystem::Init(const string& map, File file; file.name = splits[0].as_string(); file.extents = {ExtentForBytes(kBlockSize, start, cur_offset - start)}; + file.is_compressed = is_compressed; files_.emplace_back(file); } } |