aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-20 04:07:37 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-11-20 04:07:37 +0000
commit2abc3b23a54ec41b6a914b7247eb6e488bfe0a88 (patch)
treee796a37895a74a9ecffab0478f63011c8711b73c
parent16c13849891b65d6ff8ba402ef1e2e2dd306d66d (diff)
parent11a3a4cd409d6e0f4ccfcfb97cc962eeaeddde00 (diff)
downloadzucchini-android13-release.tar.gz
Snap for 7933753 from 11a3a4cd409d6e0f4ccfcfb97cc962eeaeddde00 to tm-releaseandroid-vts-13.0_r7android-vts-13.0_r6android-vts-13.0_r5android-vts-13.0_r4android-vts-13.0_r3android-vts-13.0_r2android-vts-13.0_r1android-security-13.0.0_r9android-security-13.0.0_r8android-security-13.0.0_r7android-security-13.0.0_r6android-security-13.0.0_r5android-security-13.0.0_r4android-security-13.0.0_r3android-security-13.0.0_r2android-security-13.0.0_r16android-security-13.0.0_r15android-security-13.0.0_r14android-security-13.0.0_r13android-security-13.0.0_r12android-security-13.0.0_r11android-security-13.0.0_r10android-security-13.0.0_r1android-platform-13.0.0_r9android-platform-13.0.0_r8android-platform-13.0.0_r7android-platform-13.0.0_r6android-platform-13.0.0_r5android-platform-13.0.0_r4android-platform-13.0.0_r3android-platform-13.0.0_r2android-platform-13.0.0_r18android-platform-13.0.0_r17android-platform-13.0.0_r16android-platform-13.0.0_r15android-platform-13.0.0_r14android-platform-13.0.0_r13android-platform-13.0.0_r12android-platform-13.0.0_r11android-platform-13.0.0_r10android-platform-13.0.0_r1android-cts-13.0_r7android-cts-13.0_r6android-cts-13.0_r5android-cts-13.0_r4android-cts-13.0_r3android-cts-13.0_r2android-cts-13.0_r1android-13.0.0_r8android-13.0.0_r7android-13.0.0_r6android-13.0.0_r5android-13.0.0_r4android-13.0.0_r31android-13.0.0_r3android-13.0.0_r2android-13.0.0_r12android-13.0.0_r1android13-tests-releaseandroid13-security-releaseandroid13-s3-releaseandroid13-s2-releaseandroid13-s1-releaseandroid13-releaseandroid13-platform-releaseandroid13-gsi
Change-Id: I3d7bf05c2b3379dac571d8e5a6b31213f9bf14ff
-rw-r--r--BUILD.gn1
-rw-r--r--aosp/include/base/check_op.h2
l---------aosp/include/components/zucchini/version_info.h1
-rw-r--r--element_detection.cc2
-rw-r--r--main_utils.cc2
-rw-r--r--mapped_file_unittest.cc4
-rw-r--r--patch_read_write_unittest.cc1
-rw-r--r--patch_reader.cc1
-rw-r--r--patch_utils.h12
-rw-r--r--patch_writer.cc1
-rw-r--r--version_info.h30
-rw-r--r--zucchini_commands.cc10
-rw-r--r--zucchini_integration.cc13
13 files changed, 54 insertions, 26 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 54b06ab..9fa2ea9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -97,6 +97,7 @@ static_library("zucchini_lib") {
"type_elf.h",
"type_win_pe.h",
"typed_value.h",
+ "version_info.h",
"zucchini.h",
"zucchini_apply.cc",
"zucchini_apply.h",
diff --git a/aosp/include/base/check_op.h b/aosp/include/base/check_op.h
index d72e4a4..47162e6 100644
--- a/aosp/include/base/check_op.h
+++ b/aosp/include/base/check_op.h
@@ -19,4 +19,6 @@
#include <base/logging.h>
+#define FLAG_WIN_SHARE_DELETE FLAG_SHARE_DELETE
+
#endif /* __ZUCCHINI_AOSP_BASE_CHECK_OP_H */
diff --git a/aosp/include/components/zucchini/version_info.h b/aosp/include/components/zucchini/version_info.h
new file mode 120000
index 0000000..be765ba
--- /dev/null
+++ b/aosp/include/components/zucchini/version_info.h
@@ -0,0 +1 @@
+../../../../version_info.h \ No newline at end of file
diff --git a/element_detection.cc b/element_detection.cc
index 5548610..2d260e4 100644
--- a/element_detection.cc
+++ b/element_detection.cc
@@ -9,7 +9,7 @@
#include "components/zucchini/buildflags.h"
#include "components/zucchini/disassembler.h"
#include "components/zucchini/disassembler_no_op.h"
-#include "components/zucchini/patch_utils.h"
+#include "components/zucchini/version_info.h"
#if BUILDFLAG(ENABLE_DEX)
#include "components/zucchini/disassembler_dex.h"
diff --git a/main_utils.cc b/main_utils.cc
index b499817..48b52e1 100644
--- a/main_utils.cc
+++ b/main_utils.cc
@@ -22,7 +22,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/zucchini/io_utils.h"
-#include "components/zucchini/patch_utils.h"
+#include "components/zucchini/version_info.h"
#include "components/zucchini/zucchini_commands.h"
#if defined(OS_WIN)
diff --git a/mapped_file_unittest.cc b/mapped_file_unittest.cc
index e3ee6dc..56014b0 100644
--- a/mapped_file_unittest.cc
+++ b/mapped_file_unittest.cc
@@ -33,7 +33,7 @@ TEST_F(MappedFileWriterTest, Keep) {
{
using base::File;
File file(file_path_, File::FLAG_CREATE_ALWAYS | File::FLAG_READ |
- File::FLAG_WRITE | File::FLAG_SHARE_DELETE |
+ File::FLAG_WRITE | File::FLAG_WIN_SHARE_DELETE |
File::FLAG_CAN_DELETE_ON_CLOSE);
MappedFileWriter file_writer(file_path_, std::move(file), 10);
EXPECT_FALSE(file_writer.HasError());
@@ -49,7 +49,7 @@ TEST_F(MappedFileWriterTest, DeleteOnClose) {
{
using base::File;
File file(file_path_, File::FLAG_CREATE_ALWAYS | File::FLAG_READ |
- File::FLAG_WRITE | File::FLAG_SHARE_DELETE |
+ File::FLAG_WRITE | File::FLAG_WIN_SHARE_DELETE |
File::FLAG_CAN_DELETE_ON_CLOSE);
MappedFileWriter file_writer(file_path_, std::move(file), 10);
EXPECT_FALSE(file_writer.HasError());
diff --git a/patch_read_write_unittest.cc b/patch_read_write_unittest.cc
index 25e1fb0..cce590d 100644
--- a/patch_read_write_unittest.cc
+++ b/patch_read_write_unittest.cc
@@ -11,6 +11,7 @@
#include <utility>
#include <vector>
+#include "components/zucchini/version_info.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace zucchini {
diff --git a/patch_reader.cc b/patch_reader.cc
index 8fd9b57..50ee199 100644
--- a/patch_reader.cc
+++ b/patch_reader.cc
@@ -11,6 +11,7 @@
#include "components/zucchini/algorithm.h"
#include "components/zucchini/crc32.h"
#include "components/zucchini/element_detection.h"
+#include "components/zucchini/version_info.h"
namespace zucchini {
diff --git a/patch_utils.h b/patch_utils.h
index 822fedc..82b2b48 100644
--- a/patch_utils.h
+++ b/patch_utils.h
@@ -11,20 +11,10 @@
#include <type_traits>
#include "components/zucchini/image_utils.h"
+#include "components/zucchini/version_info.h"
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.
diff --git a/patch_writer.cc b/patch_writer.cc
index 04f3244..186ece8 100644
--- a/patch_writer.cc
+++ b/patch_writer.cc
@@ -11,6 +11,7 @@
#include "base/numerics/safe_conversions.h"
#include "components/zucchini/crc32.h"
#include "components/zucchini/element_detection.h"
+#include "components/zucchini/version_info.h"
namespace zucchini {
diff --git a/version_info.h b/version_info.h
new file mode 100644
index 0000000..c6d2fac
--- /dev/null
+++ b/version_info.h
@@ -0,0 +1,30 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ZUCCHINI_VERSION_INFO_H_
+#define COMPONENTS_ZUCCHINI_VERSION_INFO_H_
+
+// This file serves as a stable location for main Zucchini version constants,
+// whose names and types should also be stable. These allow external tools to
+// determine Zucchini version at compile time by inclusion or parsing.
+
+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 };
+
+// A empty or error value for major or minor version numbers.
+enum : uint16_t { kInvalidVersion = 0xffff };
+
+} // namespace zucchini
+
+#endif // COMPONENTS_ZUCCHINI_VERSION_INFO_H_
diff --git a/zucchini_commands.cc b/zucchini_commands.cc
index 0699cbe..225fc25 100644
--- a/zucchini_commands.cc
+++ b/zucchini_commands.cc
@@ -60,7 +60,7 @@ zucchini::status::Code MainRead(MainParams params) {
CHECK_EQ(1U, params.file_paths.size());
base::File input_file(params.file_paths[0],
base::File::FLAG_OPEN | base::File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
zucchini::MappedFileReader input(std::move(input_file));
if (input.HasError()) {
LOG(ERROR) << "Error with file " << params.file_paths[0].value() << ": "
@@ -80,7 +80,7 @@ zucchini::status::Code MainDetect(MainParams params) {
CHECK_EQ(1U, params.file_paths.size());
base::File input_file(params.file_paths[0],
base::File::FLAG_OPEN | base::File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
zucchini::MappedFileReader input(std::move(input_file));
if (input.HasError()) {
LOG(ERROR) << "Error with file " << params.file_paths[0].value() << ": "
@@ -100,7 +100,7 @@ zucchini::status::Code MainMatch(MainParams params) {
CHECK_EQ(2U, params.file_paths.size());
using base::File;
File old_file(params.file_paths[0], File::FLAG_OPEN | File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
zucchini::MappedFileReader old_image(std::move(old_file));
if (old_image.HasError()) {
LOG(ERROR) << "Error with file " << params.file_paths[0].value() << ": "
@@ -108,7 +108,7 @@ zucchini::status::Code MainMatch(MainParams params) {
return zucchini::status::kStatusFileReadError;
}
File new_file(params.file_paths[1], File::FLAG_OPEN | File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
zucchini::MappedFileReader new_image(std::move(new_file));
if (new_image.HasError()) {
LOG(ERROR) << "Error with file " << params.file_paths[1].value() << ": "
@@ -131,7 +131,7 @@ zucchini::status::Code MainCrc32(MainParams params) {
CHECK_EQ(1U, params.file_paths.size());
base::File image_file(params.file_paths[0],
base::File::FLAG_OPEN | base::File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
zucchini::MappedFileReader image(std::move(image_file));
if (image.HasError()) {
LOG(ERROR) << "Error with file " << params.file_paths[0].value() << ": "
diff --git a/zucchini_integration.cc b/zucchini_integration.cc
index bf28b3c..c654a08 100644
--- a/zucchini_integration.cc
+++ b/zucchini_integration.cc
@@ -184,11 +184,12 @@ status::Code Generate(const base::FilePath& old_path,
std::string imposed_matches) {
using base::File;
File old_file(old_path, File::FLAG_OPEN | File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
File new_file(new_path, File::FLAG_OPEN | File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
File patch_file(patch_path, File::FLAG_CREATE_ALWAYS | File::FLAG_READ |
- File::FLAG_WRITE | File::FLAG_SHARE_DELETE |
+ File::FLAG_WRITE |
+ File::FLAG_WIN_SHARE_DELETE |
File::FLAG_CAN_DELETE_ON_CLOSE);
const FileNames file_names(old_path, new_path, patch_path);
return GenerateCommon(std::move(old_file), std::move(new_file),
@@ -211,11 +212,11 @@ status::Code Apply(const base::FilePath& old_path,
bool force_keep) {
using base::File;
File old_file(old_path, File::FLAG_OPEN | File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
File patch_file(patch_path, File::FLAG_OPEN | File::FLAG_READ |
- base::File::FLAG_SHARE_DELETE);
+ base::File::FLAG_WIN_SHARE_DELETE);
File new_file(new_path, File::FLAG_CREATE_ALWAYS | File::FLAG_READ |
- File::FLAG_WRITE | File::FLAG_SHARE_DELETE |
+ File::FLAG_WRITE | File::FLAG_WIN_SHARE_DELETE |
File::FLAG_CAN_DELETE_ON_CLOSE);
const FileNames file_names(old_path, new_path, patch_path);
return ApplyCommon(std::move(old_file), std::move(patch_file),