update_engine: Merge contiguous operations (reprise).
This is reapplying CL:269604 with a small fix that prevents it from
adding spurious src_length fields when merging payload operations. This
also revises relevant unit tests to catch the said error. The original
change is described below.
Merges operations of type SOURCE_COPY, REPLACE, or REPLACE_BZ if they
have the same type, are contiguous, have only one destination extent,
and their combined block count does not exceed the chunk size.
BUG=chromium:461651
BUG=chromium:486497
TEST=Unit test (fails before fix, passes after)
TEST=Trybot
Change-Id: I9f3d7f653454e27177428f2d7c0e6485184a7f8b
Reviewed-on: https://chromium-review.googlesource.com/270268
Trybot-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/payload_generator/annotated_operation.h b/payload_generator/annotated_operation.h
index e370cfe..d07b6ae 100644
--- a/payload_generator/annotated_operation.h
+++ b/payload_generator/annotated_operation.h
@@ -8,6 +8,7 @@
#include <ostream> // NOLINT(readability/streams)
#include <string>
+#include <chromeos/secure_blob.h>
#include "update_engine/update_metadata.pb.h"
namespace chromeos_update_engine {
@@ -23,6 +24,12 @@
// Sets |name| to a human readable representation of a chunk in a file.
void SetNameFromFileAndChunk(const std::string& filename,
off_t chunk_offset, off_t chunk_size);
+
+ // Writes |blob| to the end of |data_fd|, and updates |data_file_size| to
+ // match the new size of |data_fd|. It sets the data_offset and data_length
+ // in AnnotatedOperation to match the offset and size of |blob| in |data_fd|.
+ bool SetOperationBlob(chromeos::Blob* blob, int data_fd,
+ off_t* data_file_size);
};
// For logging purposes.