summaryrefslogtreecommitdiff
path: root/payload_consumer/file_descriptor_utils.cc
AgeCommit message (Collapse)Author
2021-04-20Refactor extent writer to take filedescriptor in constructorKelvin Zhang
Functions which receive an instance of extent writer need to manually pass fd to ExtentWriter via Init() call, which breaks separation of concerns. It makes it hard for us to decouple InstallOp execution from writing of data, as the execution unit must be aware of which fd to pass to extent writer. In addition, many extents writer, such as snapshot extent writer, simply ignores the fd parameter, which is a indication of poor code structure. To address the above issue, we pass FileDescriptorPtr via constructor if needed. This way, whoever is "executing" InstallOps don't need to care about where the output data is going, and whoever's writing the data would be responsible for initializing an ExtentWriter. Test: th Change-Id: I6d1eabde085eefd55da9ecc0352d4a16ae458698
2018-11-02Remove ZeroPadExtentWriter.Sen Jiang
We don't generate replace operations with trailing zero removed, so we can remove ZeroPadExtentWriter and ExtentWriter::End(). Bug: 78792859 Test: update_engine_unittests Test: brillo_update_payload verify Change-Id: I3c36d80a9c4475fda0b32c86c6503ab8b179b88f
2018-05-30Recover source hash failures on other source operations.Sen Jiang
In addition to SOURCE_COPY, now SOURCE_BSDIFF, BROTLI_BSDIFF and PUFFDIFF will also recover source hash failures using error correction data. Bug: 34284069 Test: update_engine_unittests Change-Id: I536d0675e3550aa142b77b4c8bf0a9f70a789652
2018-02-08Fix End() not called on ExtentWriter.Sen Jiang
Pass the DirectExtentWriter as a pointer to CommonHashExtents to avoid constructing the class if we are not using it. Bug: 73085863 Test: brillo_update_payload verify a delta payload Change-Id: Ie76aa1b533cafc7d649fd55316d9b1c6066822ba
2018-02-05Restructure hash calculation in delta_performerAmin Hassani
This patch moves DeltaPerformer::CalculateAndValidateHash to fd_utils::ReadAndHashExtents and cleans up the code. It also adds unittests for ReadAndHashExtents. Bug: None Test: unittest pass Change-Id: I297cf79ef38a7495d5bcc0e6516a1ca783e505ea Signed-off-by: Amin Hassani <ahassani@google.com>
2017-09-25update_engine: Use ExtentReaderAmin Hassani
Updates CopyAndHashExtents to use the new ExtentReader. Adds CalculateAndValidatffeSourceHash() to DeltaPerformer to be used in both SOURCE_BSDIFF and PUFFDIFF. BUG=chromium:761138 TEST=FEATURES="test" emerge-amd64-generic update_engine; brillo_update_payload verify Change-Id: I2e0c10fe0078c5a1ab4cd646a91d42893b6b691b Reviewed-on: https://chromium-review.googlesource.com/653478 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>
2017-09-21update_engine: Replace vector<Extent> with RepeatedPtrField<Extent>Amin Hassani
This patch removes references to vector<Extent> and replaces them with RepeatedPtrField in payload_consumer. Extent itself is a protobuf item and it makes sense to use google::protobuf::RepeatedPtrField instead of vector because then we won't have any extra copy to vector. We can directly use the list of extents given in the payload protobuf. Also removed references to vector in files which did not use vector. BUG=chromium:766397 TEST=FEATURES="test" emerge-amd64-generic update_engine Change-Id: I1f12332ff4d6303c1e4b7470bb87bf934acdf81a Reviewed-on: https://chromium-review.googlesource.com/672006 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org>
2017-08-31Move extent copy and hash logic to a new file.Alex Deymo
The SOURCE_COPY operation used to copy the source blocks one by one to the target partition. This process is sub-optimal if there are several consecutive blocks. This patch moves this copy and hash logic to a new file and adds several unittests for it. The new logic copies in chunks of up to 1MiB when the source and target data is contiguous. BUG=b:34284069 TEST=Added unittests. Change-Id: I9ed52b429a54a2b4d6edaba051284b7dcd8a9525 (cherry picked from commit a48f630400429ca010c5462967607985f2ffa7e4) Reviewed-on: https://chromium-review.googlesource.com/641958 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>