Don't use unix open() syscall on VABC partitions
Move logic dealing with target partitions to a function, such that it
can be overriden by subclasses.
Bug: 168554689
Test: treehugger
Change-Id: I59053a70915e51b0ab1b30922d14f211e1ba0605
diff --git a/payload_consumer/vabc_partition_writer.cc b/payload_consumer/vabc_partition_writer.cc
index 980f2ca..a869509 100644
--- a/payload_consumer/vabc_partition_writer.cc
+++ b/payload_consumer/vabc_partition_writer.cc
@@ -17,6 +17,7 @@
#include "update_engine/payload_consumer/vabc_partition_writer.h"
#include <memory>
+#include <string>
#include <vector>
#include <libsnapshot/cow_writer.h>
@@ -33,9 +34,15 @@
bool VABCPartitionWriter::Init(const InstallPlan* install_plan,
bool source_may_exist) {
TEST_AND_RETURN_FALSE(install_plan != nullptr);
- TEST_AND_RETURN_FALSE(PartitionWriter::Init(install_plan, source_may_exist));
+ TEST_AND_RETURN_FALSE(
+ OpenSourcePartition(install_plan->source_slot, source_may_exist));
+ std::optional<std::string> source_path;
+ if (!install_part_.source_path.empty()) {
+ // TODO(zhangkelvin) Make |source_path| a std::optional<std::string>
+ source_path = install_part_.source_path;
+ }
cow_writer_ = dynamic_control_->OpenCowWriter(
- install_part_.name, install_part_.source_path, install_plan->is_resume);
+ install_part_.name, source_path, install_plan->is_resume);
TEST_AND_RETURN_FALSE(cow_writer_ != nullptr);
// TODO(zhangkelvin) Emit a label before writing SOURCE_COPY. When resuming,