aboutsummaryrefslogtreecommitdiff
path: root/patch_utils.h
diff options
context:
space:
mode:
authorEtienne Pierre-doray <etiennep@chromium.org>2021-10-28 21:16:04 +0000
committerCopybara-Service <copybara-worker@google.com>2021-10-28 14:31:23 -0700
commitb90a947429fdce96b1d684b9a7af9683cb4a13c1 (patch)
tree333e034b74f5ec4cfb1be1600c4d1a061afbb3bc /patch_utils.h
parentaff408603b3db5b7974c522db2ad8c5ce2a0f3c1 (diff)
downloadzucchini-b90a947429fdce96b1d684b9a7af9683cb4a13c1.tar.gz
[Zucchini]: Add patch version.
This is a breaking change to zucchini patch format: Zucchini 1.0, see changelog. Add major/minor patch-wide version, and element version. Also add VerifyPatch() API and command line option to verify patch compatibility. Design: go/zucchini-versions Bug: 1231882 Change-Id: I19f1fbe2ee866c23f0814ffe6a912fb72812edbc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3140224 Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org> Cr-Commit-Position: refs/heads/main@{#936096} NOKEYCHECK=True GitOrigin-RevId: 559d77a9741428a48add017d389d104e431e6de7
Diffstat (limited to 'patch_utils.h')
-rw-r--r--patch_utils.h22
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)