Merge "libsnapshot: add check for updating next_data_pos_" into main
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
index bd69ac6..e736847 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
@@ -399,8 +399,14 @@
"operation writes.";
return false;
}
+
header_.sequence_data_count = num_ops;
+
+ // Ensure next_data_pos_ is updated as previously initialized + the newly added sequence buffer.
+ CHECK_EQ(next_data_pos_ + header_.sequence_data_count * sizeof(uint32_t),
+ GetDataOffset(header_));
next_data_pos_ = GetDataOffset(header_);
+
if (!android::base::WriteFullyAtOffset(fd_, data, sizeof(data[0]) * num_ops,
GetSequenceOffset(header_))) {
PLOG(ERROR) << "writing sequence buffer failed";