summaryrefslogtreecommitdiff
path: root/payload_consumer/filesystem_verifier_action.h
diff options
context:
space:
mode:
authorDaniel Norman <danielnorman@google.com>2021-06-18 20:06:47 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-06-18 20:06:47 +0000
commit2218a7229a48b3fe97a4054e0875327f768ab64a (patch)
treeeaf5efaa52859f5cc863de675b8436763e033c22 /payload_consumer/filesystem_verifier_action.h
parentf40f89805fa044356743206f7cfa6c8f11b8f0a2 (diff)
parent308f26179c8dba125b44d22160ba264cf17deed4 (diff)
Merge "Merge SP1A.210604.001 Change-Id: Ic0b06785e559f2b316762ba170d60370f83f7cf3" into s-keystone-qcom-dev
Diffstat (limited to 'payload_consumer/filesystem_verifier_action.h')
-rw-r--r--payload_consumer/filesystem_verifier_action.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/payload_consumer/filesystem_verifier_action.h b/payload_consumer/filesystem_verifier_action.h
index 78634cb3..850abdad 100644
--- a/payload_consumer/filesystem_verifier_action.h
+++ b/payload_consumer/filesystem_verifier_action.h
@@ -22,12 +22,14 @@
#include <memory>
#include <string>
+#include <utility>
#include <vector>
#include <brillo/message_loops/message_loop.h>
#include "update_engine/common/action.h"
#include "update_engine/common/hash_calculator.h"
+#include "update_engine/common/scoped_task_id.h"
#include "update_engine/payload_consumer/file_descriptor.h"
#include "update_engine/payload_consumer/install_plan.h"
#include "update_engine/payload_consumer/verity_writer_interface.h"
@@ -84,6 +86,16 @@ class FilesystemVerifierAction : public InstallPlanAction {
private:
friend class FilesystemVerifierActionTestDelegate;
+ void WriteVerityAndHashPartition(FileDescriptorPtr fd,
+ const off64_t start_offset,
+ const off64_t end_offset,
+ void* buffer,
+ const size_t buffer_size);
+ void HashPartition(FileDescriptorPtr fd,
+ const off64_t start_offset,
+ const off64_t end_offset,
+ void* buffer,
+ const size_t buffer_size);
// Return true if we need to write verity bytes.
bool ShouldWriteVerity();
@@ -91,16 +103,11 @@ class FilesystemVerifierAction : public InstallPlanAction {
// remaining to be hashed, it finishes the action.
void StartPartitionHashing();
- // Schedules the asynchronous read of the filesystem part of this
- // partition(not including hashtree/verity).
- void ScheduleFileSystemRead();
+ const std::string& GetPartitionPath() const;
- // Read the verity part of this partition.(hash tree and FEC)
- void ReadVerityAndFooter();
+ bool IsVABC(const InstallPlan::Partition& partition) const;
- // Called from the main loop when a single read from |src_stream_| succeeds or
- // fails, calling OnReadDoneCallback() and OnReadErrorCallback() respectively.
- void OnReadDone(size_t bytes_read);
+ size_t GetPartitionSize() const;
// When the read is done, finalize the hash checking of the current partition
// and continue checking the next one.
@@ -114,9 +121,13 @@ class FilesystemVerifierAction : public InstallPlanAction {
// Invoke delegate callback to report progress, if delegate is not null
void UpdateProgress(double progress);
+ // Updates progress of current partition. |progress| should be in range [0,
+ // 1], and it will be scaled appropriately with # of partitions.
+ void UpdatePartitionProgress(double progress);
+
// Initialize read_fd_ and write_fd_
bool InitializeFd(const std::string& part_path);
- bool InitializeFdVABC();
+ bool InitializeFdVABC(bool should_write_verity);
// The type of the partition that we are verifying.
VerifierStep verifier_step_ = VerifierStep::kVerifyTargetHash;
@@ -161,8 +172,7 @@ class FilesystemVerifierAction : public InstallPlanAction {
// Callback that should be cancelled on |TerminateProcessing|. Usually this
// points to pending read callbacks from async stream.
- brillo::MessageLoop::TaskId pending_task_id_{
- brillo::MessageLoop::kTaskIdNull};
+ ScopedTaskId pending_task_id_;
DISALLOW_COPY_AND_ASSIGN(FilesystemVerifierAction);
};