Merge "disable sync_on_suspend when flag is set" into main
diff --git a/fs_mgr/libsnapshot/tools/Android.bp b/fs_mgr/libsnapshot/tools/Android.bp
index cfa0cef..0f08286 100644
--- a/fs_mgr/libsnapshot/tools/Android.bp
+++ b/fs_mgr/libsnapshot/tools/Android.bp
@@ -20,3 +20,26 @@
cflags: ["-Werror"],
}
+
+
+cc_binary {
+ name: "basic_v2_cow_writer",
+ host_supported: true,
+ defaults: [
+ "fs_mgr_defaults",
+ "libsnapshot_cow_defaults",
+ ],
+
+ srcs: ["basic_v2_cow_writer.cpp"],
+
+ static_libs: [
+ "libsnapshot_cow",
+ ],
+
+ shared_libs: [
+ "libbase",
+ "liblog",
+ ],
+
+ cflags: ["-Werror"],
+}
diff --git a/fs_mgr/libsnapshot/tools/basic_v2_cow_writer.cpp b/fs_mgr/libsnapshot/tools/basic_v2_cow_writer.cpp
new file mode 100644
index 0000000..72fb0f5
--- /dev/null
+++ b/fs_mgr/libsnapshot/tools/basic_v2_cow_writer.cpp
@@ -0,0 +1,63 @@
+//
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <libsnapshot/cow_compress.h>
+#include <libsnapshot/cow_format.h>
+#include <libsnapshot/cow_writer.h>
+#include <filesystem>
+
+#include "android-base/unique_fd.h"
+
+using namespace android::snapshot;
+
+// This writes a simple cow v2 file in the current directory. This file will serve as testdata for
+// ensuring our v3 cow reader will be able to read a cow file created by the v2 writer.
+//
+// WARNING: We should not be overriding this test file, as it will serve as historic marker for what
+// a device with old writer_v2 will write as a cow.
+void write_cow_v2() {
+ CowOptions options;
+ options.cluster_ops = 5;
+ options.num_merge_ops = 1;
+ std::string data = "This is some data, believe it";
+ data.resize(options.block_size, '\0');
+
+ char cwd_buffer[1024];
+ size_t cwd_buffer_size = sizeof(cwd_buffer);
+
+ // Get the current working directory path.
+ char* err = getcwd(cwd_buffer, cwd_buffer_size);
+ if (!err) {
+ LOG(ERROR) << "Couldn't get current directory";
+ }
+ android::base::unique_fd fd(open(strcat(cwd_buffer, "/cow_v2"), O_CREAT | O_RDWR, 0666));
+ if (fd.get() == -1) {
+ LOG(FATAL) << "couldn't open tmp_cow";
+ }
+ std::unique_ptr<ICowWriter> writer = CreateCowWriter(2, options, std::move(fd));
+ writer->AddCopy(0, 5);
+ writer->AddRawBlocks(2, data.data(), data.size());
+ writer->AddLabel(1);
+ writer->AddXorBlocks(50, data.data(), data.size(), 24, 10);
+ writer->AddZeroBlocks(5, 10);
+ writer->AddLabel(2);
+ writer->Finalize();
+}
+
+int main() {
+ write_cow_v2();
+}
diff --git a/fs_mgr/libsnapshot/tools/cow_benchmark.cpp b/fs_mgr/libsnapshot/tools/cow_benchmark.cpp
index da2b879..4d5e346 100644
--- a/fs_mgr/libsnapshot/tools/cow_benchmark.cpp
+++ b/fs_mgr/libsnapshot/tools/cow_benchmark.cpp
@@ -1,4 +1,18 @@
-
+//
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
#include <memory>
#include <array>
diff --git a/fs_mgr/libsnapshot/tools/testdata/cow_v2 b/fs_mgr/libsnapshot/tools/testdata/cow_v2
new file mode 100644
index 0000000..9f37dfc
--- /dev/null
+++ b/fs_mgr/libsnapshot/tools/testdata/cow_v2
Binary files differ
diff --git a/trusty/utils/coverage-controller/controller.cpp b/trusty/utils/coverage-controller/controller.cpp
index 0047046..381a452 100644
--- a/trusty/utils/coverage-controller/controller.cpp
+++ b/trusty/utils/coverage-controller/controller.cpp
@@ -54,7 +54,7 @@
if (complete_cnt != counters[index] && start_cnt == complete_cnt) {
WRITE_ONCE(control->cntrl_flags, FLAG_NONE);
std::string filename;
- filename = android::base::StringPrintf("/%s.%lu.profraw",
+ filename = android::base::StringPrintf("/%s.%" PRIu64 ".profraw",
uuid_list_[index].c_str(),
counters[index]);
filename.insert(0, output_dir);