summaryrefslogtreecommitdiff
path: root/common/dynamic_partition_control_interface.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/dynamic_partition_control_interface.h')
-rw-r--r--common/dynamic_partition_control_interface.h73
1 files changed, 72 insertions, 1 deletions
diff --git a/common/dynamic_partition_control_interface.h b/common/dynamic_partition_control_interface.h
index 58ebfe46..a5be6e1a 100644
--- a/common/dynamic_partition_control_interface.h
+++ b/common/dynamic_partition_control_interface.h
@@ -21,14 +21,28 @@
#include <memory>
#include <string>
+#include <vector>
#include "update_engine/common/action.h"
#include "update_engine/common/cleanup_previous_update_action_delegate.h"
#include "update_engine/common/error_code.h"
+#include "update_engine/common/prefs_interface.h"
+#include "update_engine/payload_consumer/file_descriptor.h"
#include "update_engine/update_metadata.pb.h"
+// Forware declare for libsnapshot/snapshot_writer.h
+namespace android::snapshot {
+class ISnapshotWriter;
+}
+
namespace chromeos_update_engine {
+struct PartitionDevice {
+ std::string rw_device_path;
+ std::string readonly_device_path;
+ bool is_dynamic;
+};
+
struct FeatureFlag {
enum class Value { NONE = 0, RETROFIT, LAUNCH };
constexpr explicit FeatureFlag(Value value) : value_(value) {}
@@ -41,7 +55,6 @@ struct FeatureFlag {
};
class BootControlInterface;
-class PrefsInterface;
class DynamicPartitionControlInterface {
public:
@@ -55,6 +68,11 @@ class DynamicPartitionControlInterface {
// Return the feature flags of Virtual A/B on this device.
virtual FeatureFlag GetVirtualAbFeatureFlag() = 0;
+ // Return the feature flags of Virtual A/B Compression on this device.
+ // This function will tell you if current device supports VABC. However, it
+ // DOES NOT tell you if VABC is used for current OTA update. For that, use
+ // UpdateUsesSnapshotCompression.
+ virtual FeatureFlag GetVirtualAbCompressionFeatureFlag() = 0;
// Attempt to optimize |operation|.
// If successful, |optimized| contains an operation with extents that
@@ -118,6 +136,59 @@ class DynamicPartitionControlInterface {
// progress, while ResetUpdate() forcefully free previously
// allocated space for snapshot updates.
virtual bool ResetUpdate(PrefsInterface* prefs) = 0;
+
+ // Reads the dynamic partitions metadata from the given slot, and puts the
+ // name of the dynamic partitions with the current suffix to |partitions|.
+ // Returns true on success.
+ virtual bool ListDynamicPartitionsForSlot(
+ uint32_t slot,
+ uint32_t current_slot,
+ std::vector<std::string>* partitions) = 0;
+
+ // Finds a possible location that list all block devices by name; and puts
+ // the result in |path|. Returns true on success.
+ // Sample result: /dev/block/by-name/
+ virtual bool GetDeviceDir(std::string* path) = 0;
+
+ // Verifies that the untouched dynamic partitions in the target metadata have
+ // the same extents as the source metadata.
+ virtual bool VerifyExtentsForUntouchedPartitions(
+ uint32_t source_slot,
+ uint32_t target_slot,
+ const std::vector<std::string>& partitions) = 0;
+ // Partition name is expected to be unsuffixed. e.g. system, vendor
+ // Return an interface to write to a snapshoted partition.
+ // If `is_append` is false, then existing COW data will be overwritten.
+ // Otherwise the cow writer will be opened on APPEND mode, existing COW data
+ // is preserved.
+ virtual std::unique_ptr<android::snapshot::ISnapshotWriter> OpenCowWriter(
+ const std::string& unsuffixed_partition_name,
+ const std::optional<std::string>&,
+ bool is_append = false) = 0;
+ // Open a general purpose FD capable to reading and writing to COW. Note that
+ // writes must be block aligned.
+ virtual FileDescriptorPtr OpenCowFd(
+ const std::string& unsuffixed_partition_name,
+ const std::optional<std::string>&,
+ bool is_append = false) = 0;
+
+ virtual bool IsDynamicPartition(const std::string& part_name,
+ uint32_t slot) = 0;
+
+ // Create virtual block devices for all partitions.
+ virtual bool MapAllPartitions() = 0;
+ // Unmap virtual block devices for all partitions.
+ virtual bool UnmapAllPartitions() = 0;
+
+ // Return if snapshot compression is enabled for this update.
+ // This function should only be called after preparing for an update
+ // (PreparePartitionsForUpdate), and before merging
+ // (see GetCleanupPreviousUpdateAction and CleanupPreviousUpdateAction) or
+ // resetting it (ResetUpdate).
+ //
+ // To know if the device supports snapshot compression by itself, use
+ // GetVirtualAbCompressionFeatureFlag
+ virtual bool UpdateUsesSnapshotCompression() = 0;
};
} // namespace chromeos_update_engine