Snap for 11494200 from 33aa40e6b9c0e8e2e8082c29f1638d1e5079f116 to 24Q2-release
Change-Id: Ie537046b7ee68e2ab4d5730b6e65dadc298dd373
diff --git a/debuggerd/tombstoned/tombstoned.cpp b/debuggerd/tombstoned/tombstoned.cpp
index cf7904f..e79035f 100644
--- a/debuggerd/tombstoned/tombstoned.cpp
+++ b/debuggerd/tombstoned/tombstoned.cpp
@@ -417,6 +417,7 @@
return false;
}
+ // This fd is created inside of dirfd in CrashQueue::create_temporary_file.
std::string fd_path = StringPrintf("/proc/self/fd/%d", fd.get());
rc = linkat(AT_FDCWD, fd_path.c_str(), dirfd.get(), path.c_str(), AT_SYMLINK_FOLLOW);
if (rc != 0) {
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index cbe8285..e6c4de6 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -508,8 +508,6 @@
// When snapshots are on current slot, we determine the size
// of block device based on the number of COW operations. We cannot
// use base device as it will be from older image.
- size_t num_ops = 0;
- uint64_t dev_sz = 0;
unique_fd fd(open(cow_file.c_str(), O_RDONLY | O_CLOEXEC));
if (fd < 0) {
PLOG(ERROR) << "Failed to open " << cow_file;
@@ -522,13 +520,18 @@
return false;
}
+ uint64_t dev_sz = 0;
const auto& header = reader.GetHeader();
- if (header.prefix.major_version > 2) {
- LOG(ERROR) << "COW format not supported";
- return false;
+ if (header.prefix.major_version == 2) {
+ const size_t num_ops = reader.get_num_total_data_ops();
+ dev_sz = (num_ops * header.block_size);
+ } else {
+ // create_snapshot will skip in-place copy ops. Hence, fetch this
+ // information directly from v3 header.
+ const auto& v3_header = reader.header_v3();
+ dev_sz = v3_header.op_count_max * v3_header.block_size;
}
- num_ops = reader.get_num_total_data_ops();
- dev_sz = (num_ops * header.block_size);
+
base_sectors = dev_sz >> 9;
} else {
// For userspace snapshots, the size of the base device is taken as the