Use file size instead of filesystem size for all partitions.
Bug: 23420126
TEST=cros_workon_make update_engine --test
Change-Id: I994f527403a31234d7a3fed82ba43220149a555f
diff --git a/delta_performer_integration_test.cc b/delta_performer_integration_test.cc
index eddce9c..143d21d 100644
--- a/delta_performer_integration_test.cc
+++ b/delta_performer_integration_test.cc
@@ -305,11 +305,6 @@
state->image_size = utils::FileSize(state->a_img);
- // Extend the "partitions" holding the file system a bit.
- EXPECT_EQ(0, HANDLE_EINTR(truncate(state->a_img.c_str(),
- state->image_size + 1024 * 1024)));
- EXPECT_EQ(state->image_size + 1024 * 1024, utils::FileSize(state->a_img));
-
// Create ImageInfo A & B
ImageInfo old_image_info;
ImageInfo new_image_info;
@@ -376,10 +371,8 @@
old_image_info = new_image_info;
} else {
if (minor_version == kSourceMinorPayloadVersion) {
- // Create a result image with image_size bytes of garbage, followed by
- // zeroes after the rootfs, like image A and B have.
+ // Create a result image with image_size bytes of garbage.
chromeos::Blob ones(state->image_size, 0xff);
- ones.insert(ones.end(), 1024 * 1024, 0);
EXPECT_TRUE(utils::WriteFile(state->result_img.c_str(),
ones.data(),
ones.size()));
@@ -388,9 +381,6 @@
}
test_utils::CreateExtImageAtPath(state->b_img, nullptr);
- EXPECT_EQ(0, HANDLE_EINTR(truncate(state->b_img.c_str(),
- state->image_size + 1024 * 1024)));
- EXPECT_EQ(state->image_size + 1024 * 1024, utils::FileSize(state->b_img));
// Make some changes to the B image.
string b_mnt;
@@ -537,6 +527,13 @@
private_key,
&state->metadata_size));
}
+ // Extend the "partitions" holding the file system a bit.
+ EXPECT_EQ(0, HANDLE_EINTR(truncate(state->a_img.c_str(),
+ state->image_size + 1024 * 1024)));
+ EXPECT_EQ(state->image_size + 1024 * 1024, utils::FileSize(state->a_img));
+ EXPECT_EQ(0, HANDLE_EINTR(truncate(state->b_img.c_str(),
+ state->image_size + 1024 * 1024)));
+ EXPECT_EQ(state->image_size + 1024 * 1024, utils::FileSize(state->b_img));
if (signature_test == kSignatureGeneratedPlaceholder ||
signature_test == kSignatureGeneratedPlaceholderMismatch) {
diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc
index 786c4e2..2de696a 100644
--- a/payload_generator/payload_generation_config.cc
+++ b/payload_generator/payload_generation_config.cc
@@ -33,6 +33,16 @@
// The requested size is within the limits of the file.
TEST_AND_RETURN_FALSE(static_cast<off_t>(size) <=
utils::FileSize(path.c_str()));
+ // TODO(deymo): The delta generator algorithm doesn't support a block size
+ // different than 4 KiB. Remove this check once that's fixed. crbug.com/455045
+ int block_count, block_size;
+ if (utils::GetFilesystemSize(path, &block_count, &block_size) &&
+ block_size != 4096) {
+ LOG(ERROR) << "The filesystem provided in " << path
+ << " has a block size of " << block_size
+ << " but delta_generator only supports 4096.";
+ return false;
+ }
return true;
}
@@ -67,22 +77,9 @@
bool ImageConfig::LoadImageSize() {
TEST_AND_RETURN_FALSE(!rootfs.path.empty());
- int rootfs_block_count, rootfs_block_size;
- TEST_AND_RETURN_FALSE(utils::GetFilesystemSize(rootfs.path,
- &rootfs_block_count,
- &rootfs_block_size));
- rootfs.size = static_cast<uint64_t>(rootfs_block_count) * rootfs_block_size;
+ rootfs.size = utils::FileSize(rootfs.path);
if (!kernel.path.empty())
kernel.size = utils::FileSize(kernel.path);
-
- // TODO(deymo): The delta generator algorithm doesn't support a block size
- // different than 4 KiB. Remove this check once that's fixed. crbug.com/455045
- if (rootfs_block_size != 4096) {
- LOG(ERROR) << "The filesystem provided in " << rootfs.path
- << " has a block size of " << rootfs_block_size
- << " but delta_generator only supports 4096.";
- return false;
- }
return true;
}