diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2021-11-02 21:45:15 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-11-02 21:45:15 +0000 |
commit | 7be427590935bc88198d32004449ccfcf60b60d4 (patch) | |
tree | 0a310ca653ef73c547d80da63c87fcb2c0636bcb /patch_utils.h | |
parent | 4ec021d20924840a50ba05f6bca56bac326cf0c8 (diff) | |
parent | 58b4d19a6b6c8a6790c31bb3d6fcd13a8892239b (diff) | |
download | zucchini-7be427590935bc88198d32004449ccfcf60b60d4.tar.gz |
Merge remote-tracking branch 'aosp/upstream-main' into dev am: a90c04389f am: ddc43dc959 am: d9eed84a58 am: 58b4d19a6b
Original change: https://android-review.googlesource.com/c/platform/external/zucchini/+/1877854
Change-Id: I31da7b51c793e73f8a66b1fd4ca9be90ae6e6df2
Diffstat (limited to 'patch_utils.h')
-rw-r--r-- | patch_utils.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/patch_utils.h b/patch_utils.h index 5f49195..822fedc 100644 --- a/patch_utils.h +++ b/patch_utils.h @@ -14,6 +14,17 @@ namespace zucchini { +// A change in major version indicates breaking changes such that a patch +// definitely cannot be applied by a zucchini binary whose major version doesn't +// match. +enum : uint16_t { kMajorVersion = 1 }; +// A change in minor version indicates possibly breaking changes at the element +// level, such that it may not be possible to apply a patch whose minor version +// doesn't match this version. To determine if a given patch may be applied with +// this version, VerifyPatch() should be called. +enum : uint16_t { kMinorVersion = 0 }; +enum : uint16_t { kInvalidVersion = 0xffff }; + // A Zucchini 'ensemble' patch is the concatenation of a patch header with a // list of patch 'elements', each containing data for patching individual // elements. @@ -24,9 +35,11 @@ namespace zucchini { // Header for a Zucchini patch, found at the beginning of an ensemble patch. struct PatchHeader { // Magic signature at the beginning of a Zucchini patch file. - enum : uint32_t { kMagic = 'Z' | ('u' << 8) | ('c' << 16) }; + enum : uint32_t { kMagic = 'Z' | ('u' << 8) | ('c' << 16) | ('c' << 24) }; uint32_t magic = 0; + uint16_t major_version = kInvalidVersion; + uint16_t minor_version = kInvalidVersion; uint32_t old_size = 0; uint32_t old_crc = 0; uint32_t new_size = 0; @@ -34,7 +47,7 @@ struct PatchHeader { }; // Sanity check. -static_assert(sizeof(PatchHeader) == 20, "PatchHeader must be 20 bytes"); +static_assert(sizeof(PatchHeader) == 24, "PatchHeader must be 24 bytes"); // Header for a patch element, found at the beginning of every patch element. struct PatchElementHeader { @@ -43,11 +56,12 @@ struct PatchElementHeader { uint32_t new_offset; uint32_t new_length; uint32_t exe_type; // ExecutableType. + uint16_t version = kInvalidVersion; }; // Sanity check. -static_assert(sizeof(PatchElementHeader) == 20, - "PatchElementHeader must be 20 bytes"); +static_assert(sizeof(PatchElementHeader) == 22, + "PatchElementHeader must be 22 bytes"); #pragma pack(pop) |