summaryrefslogtreecommitdiffstats
path: root/updater/include
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-06-18 19:03:52 +0200
committerTao Bao <tbao@google.com>2018-08-17 18:37:26 +0200
commitf8811bbd3a40df5962cf6f6274802a7cfd229f2e (patch)
tree0de6a79ad32aace6b7ceff14f85936bc3ce8c383 /updater/include
parentMerge "Add a python binary to generate the protobuf for care_map" (diff)
downloadandroid_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.tar
android_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.tar.gz
android_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.tar.bz2
android_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.tar.lz
android_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.tar.xz
android_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.tar.zst
android_bootable_recovery-f8811bbd3a40df5962cf6f6274802a7cfd229f2e.zip
Diffstat (limited to 'updater/include')
-rw-r--r--updater/include/private/commands.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/updater/include/private/commands.h b/updater/include/private/commands.h
index 521289780..79f915434 100644
--- a/updater/include/private/commands.h
+++ b/updater/include/private/commands.h
@@ -406,3 +406,70 @@ class Command {
};
std::ostream& operator<<(std::ostream& os, const Command& command);
+
+// TransferList represents the info for a transfer list, which is parsed from input text lines
+// containing commands to transfer data from one place to another on the target partition.
+//
+// The creator of the transfer list will guarantee that no block is read (i.e., used as the source
+// for a patch or move) after it has been written.
+//
+// The creator will guarantee that a given stash is loaded (with a stash command) before it's used
+// in a move/bsdiff/imgdiff command.
+//
+// Within one command the source and target ranges may overlap so in general we need to read the
+// entire source into memory before writing anything to the target blocks.
+//
+// All the patch data is concatenated into one patch_data file in the update package. It must be
+// stored uncompressed because we memory-map it in directly from the archive. (Since patches are
+// already compressed, we lose very little by not compressing their concatenation.)
+//
+// Commands that read data from the partition (i.e. move/bsdiff/imgdiff/stash) have one or more
+// additional hashes before the range parameters, which are used to check if the command has
+// already been completed and verify the integrity of the source data.
+class TransferList {
+ public:
+ // Number of header lines.
+ static constexpr size_t kTransferListHeaderLines = 4;
+
+ TransferList() = default;
+
+ // Parses the given input string and returns a TransferList object. Sets error message if any.
+ static TransferList Parse(const std::string& transfer_list_str, std::string* err);
+
+ int version() const {
+ return version_;
+ }
+
+ size_t total_blocks() const {
+ return total_blocks_;
+ }
+
+ size_t stash_max_entries() const {
+ return stash_max_entries_;
+ }
+
+ size_t stash_max_blocks() const {
+ return stash_max_blocks_;
+ }
+
+ const std::vector<Command>& commands() const {
+ return commands_;
+ }
+
+ // Returns whether the TransferList is valid.
+ constexpr explicit operator bool() const {
+ return version_ != 0;
+ }
+
+ private:
+ // BBOTA version.
+ int version_{ 0 };
+ // Total number of blocks to be written in this transfer.
+ size_t total_blocks_;
+ // Maximum number of stashes that exist at the same time.
+ size_t stash_max_entries_;
+ // Maximum number of blocks to be stashed.
+ size_t stash_max_blocks_;
+ // Commands in this transfer.
+ std::vector<Command> commands_;
+};