diff options
Diffstat (limited to 'payload_generator')
-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); } } |