diff options
-rw-r--r-- | payload_generator/ab_generator.cc | 3 | ||||
-rw-r--r-- | payload_generator/delta_diff_utils_unittest.cc | 4 | ||||
-rw-r--r-- | payload_generator/full_update_generator.cc | 6 | ||||
-rw-r--r-- | payload_generator/full_update_generator_unittest.cc | 2 | ||||
-rw-r--r-- | payload_generator/inplace_generator.cc | 11 | ||||
-rw-r--r-- | payload_generator/inplace_generator_unittest.cc | 2 | ||||
-rw-r--r-- | payload_generator/payload_generation_config.cc | 14 | ||||
-rw-r--r-- | payload_generator/payload_generation_config.h | 18 |
8 files changed, 21 insertions, 39 deletions
diff --git a/payload_generator/ab_generator.cc b/payload_generator/ab_generator.cc index 459b3b93..065408bf 100644 --- a/payload_generator/ab_generator.cc +++ b/payload_generator/ab_generator.cc @@ -38,6 +38,7 @@ bool ABGenerator::GenerateOperations( const PartitionConfig& new_part, BlobFileWriter* blob_file, vector<AnnotatedOperation>* aops) { + TEST_AND_RETURN_FALSE(old_part.name == new_part.name); ssize_t hard_chunk_blocks = (config.hard_chunk_size == -1 ? -1 : config.hard_chunk_size / config.block_size); @@ -52,7 +53,7 @@ bool ABGenerator::GenerateOperations( soft_chunk_blocks, blob_file, true)); // src_ops_allowed - LOG(INFO) << "done reading " << PartitionNameString(new_part.name); + LOG(INFO) << "done reading " << new_part.name; TEST_AND_RETURN_FALSE(FragmentOperations(aops, new_part.path, diff --git a/payload_generator/delta_diff_utils_unittest.cc b/payload_generator/delta_diff_utils_unittest.cc index 4d81632a..6b231973 100644 --- a/payload_generator/delta_diff_utils_unittest.cc +++ b/payload_generator/delta_diff_utils_unittest.cc @@ -143,8 +143,8 @@ class DeltaDiffUtilsTest : public ::testing::Test { // Old and new temporary partitions used in the tests. These are initialized // with - PartitionConfig old_part_{PartitionName::kRootfs}; - PartitionConfig new_part_{PartitionName::kRootfs}; + PartitionConfig old_part_{"part"}; + PartitionConfig new_part_{"part"}; // The file holding the output blob from the various diff utils functions. string blob_path_; diff --git a/payload_generator/full_update_generator.cc b/payload_generator/full_update_generator.cc index 101f28aa..7ece2ada 100644 --- a/payload_generator/full_update_generator.cc +++ b/payload_generator/full_update_generator.cc @@ -146,7 +146,7 @@ bool FullUpdateGenerator::GenerateOperations( size_t chunk_blocks = full_chunk_size / config.block_size; size_t max_threads = std::max(sysconf(_SC_NPROCESSORS_ONLN), 4L); - LOG(INFO) << "Compressing partition " << PartitionNameString(new_part.name) + LOG(INFO) << "Compressing partition " << new_part.name << " from " << new_part.path << " splitting in chunks of " << chunk_blocks << " blocks (" << config.block_size << " bytes each) using " << max_threads << " threads"; @@ -164,8 +164,6 @@ bool FullUpdateGenerator::GenerateOperations( chunk_processors.reserve(num_chunks); blob_file->SetTotalBlobs(num_chunks); - const string part_name_str = PartitionNameString(new_part.name); - for (size_t i = 0; i < num_chunks; ++i) { size_t start_block = i * chunk_blocks; // The last chunk could be smaller. @@ -176,7 +174,7 @@ bool FullUpdateGenerator::GenerateOperations( // ChunkProcessor will set the rest. AnnotatedOperation* aop = aops->data() + i; aop->name = base::StringPrintf("<%s-operation-%" PRIuS ">", - part_name_str.c_str(), i); + new_part.name.c_str(), i); Extent* dst_extent = aop->op.add_dst_extents(); dst_extent->set_start_block(start_block); dst_extent->set_num_blocks(num_blocks); diff --git a/payload_generator/full_update_generator_unittest.cc b/payload_generator/full_update_generator_unittest.cc index ac371587..2f391268 100644 --- a/payload_generator/full_update_generator_unittest.cc +++ b/payload_generator/full_update_generator_unittest.cc @@ -52,7 +52,7 @@ class FullUpdateGeneratorTest : public ::testing::Test { } PayloadGenerationConfig config_; - PartitionConfig new_part_conf{PartitionName::kRootfs}; + PartitionConfig new_part_conf{"part"}; vector<AnnotatedOperation> aops; diff --git a/payload_generator/inplace_generator.cc b/payload_generator/inplace_generator.cc index 9d108bdd..0cfbe020 100644 --- a/payload_generator/inplace_generator.cc +++ b/payload_generator/inplace_generator.cc @@ -790,15 +790,16 @@ bool InplaceGenerator::GenerateOperations( const PartitionConfig& new_part, BlobFileWriter* blob_file, vector<AnnotatedOperation>* aops) { + TEST_AND_RETURN_FALSE(old_part.name == new_part.name); + ssize_t hard_chunk_blocks = (config.hard_chunk_size == -1 ? -1 : config.hard_chunk_size / config.block_size); size_t soft_chunk_blocks = config.soft_chunk_size / config.block_size; uint64_t partition_size = new_part.size; - if (new_part.name == PartitionName::kRootfs) + if (new_part.name == kLegacyPartitionNameRoot) partition_size = config.rootfs_partition_size; - const string part_name = PartitionNameString(new_part.name); - LOG(INFO) << "Delta compressing " << part_name << " partition..."; + LOG(INFO) << "Delta compressing " << new_part.name << " partition..."; TEST_AND_RETURN_FALSE( diff_utils::DeltaReadPartition(aops, old_part, @@ -807,7 +808,7 @@ bool InplaceGenerator::GenerateOperations( soft_chunk_blocks, blob_file, false)); // src_ops_allowed - LOG(INFO) << "Done reading " << part_name; + LOG(INFO) << "Done reading " << new_part.name; TEST_AND_RETURN_FALSE( ResolveReadAfterWriteDependencies(new_part, @@ -815,7 +816,7 @@ bool InplaceGenerator::GenerateOperations( config.block_size, blob_file, aops)); - LOG(INFO) << "Done reordering " << part_name; + LOG(INFO) << "Done reordering " << new_part.name; return true; } diff --git a/payload_generator/inplace_generator_unittest.cc b/payload_generator/inplace_generator_unittest.cc index 1cc20cf1..d6430c81 100644 --- a/payload_generator/inplace_generator_unittest.cc +++ b/payload_generator/inplace_generator_unittest.cc @@ -608,7 +608,7 @@ TEST_F(InplaceGeneratorTest, ResolveReadAfterWriteDependenciesAvoidMoveToZero) { aops.push_back(aop); } - PartitionConfig part(PartitionName::kRootfs); + PartitionConfig part("part"); part.path = "/dev/zero"; part.size = num_blocks * block_size; diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc index ecf96278..a2d93116 100644 --- a/payload_generator/payload_generation_config.cc +++ b/payload_generator/payload_generation_config.cc @@ -26,16 +26,6 @@ namespace chromeos_update_engine { -std::string PartitionNameString(PartitionName name) { - switch (name) { - case PartitionName::kKernel: - return "kernel"; - case PartitionName::kRootfs: - return "rootfs"; - } - return "other"; -} - bool PartitionConfig::ValidateExists() const { TEST_AND_RETURN_FALSE(!path.empty()); TEST_AND_RETURN_FALSE(utils::FileExists(path.c_str())); @@ -50,7 +40,7 @@ bool PartitionConfig::OpenFilesystem() { if (path.empty()) return true; fs_interface.reset(); - if (name == PartitionName::kRootfs) { + if (utils::IsExtFilesystem(path)) { fs_interface = Ext2Filesystem::CreateFromFile(path); } @@ -58,7 +48,7 @@ bool PartitionConfig::OpenFilesystem() { // Fall back to a RAW filesystem. TEST_AND_RETURN_FALSE(size % kBlockSize == 0); fs_interface = RawFilesystem::Create( - "<" + PartitionNameString(name) + "-partition>", + "<" + name + "-partition>", kBlockSize, size / kBlockSize); } diff --git a/payload_generator/payload_generation_config.h b/payload_generator/payload_generation_config.h index 4e996881..b7bd4849 100644 --- a/payload_generator/payload_generation_config.h +++ b/payload_generator/payload_generation_config.h @@ -23,22 +23,14 @@ #include <string> #include <vector> +#include "update_engine/payload_constants.h" #include "update_engine/payload_generator/filesystem_interface.h" #include "update_engine/update_metadata.pb.h" namespace chromeos_update_engine { -// The list different kind of partitions supported by the updater. -enum class PartitionName { - kKernel, - kRootfs, -}; - -// Return a string name for the PartitionName. -std::string PartitionNameString(PartitionName name); - struct PartitionConfig { - explicit PartitionConfig(PartitionName name) : name(name) {} + explicit PartitionConfig(std::string name) : name(name) {} // Returns whether the PartitionConfig is not an empty image and all the // fields are set correctly to a valid image file. @@ -64,7 +56,7 @@ struct PartitionConfig { // files. std::unique_ptr<FilesystemInterface> fs_interface; - PartitionName name; + std::string name; }; // The ImageConfig struct describes a pair of binaries kernel and rootfs and the @@ -88,8 +80,8 @@ struct ImageConfig { ImageInfo image_info; // The updated partitions. - PartitionConfig rootfs = PartitionConfig{PartitionName::kRootfs}; - PartitionConfig kernel = PartitionConfig{PartitionName::kKernel}; + PartitionConfig rootfs = PartitionConfig{kLegacyPartitionNameRoot}; + PartitionConfig kernel = PartitionConfig{kLegacyPartitionNameKernel}; }; // The PayloadGenerationConfig struct encapsulates all the configuration to |