Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2d5ec07

Browse files
zbw182Gerrit Code Review
authored andcommittedOct 10, 2023
Merge "Move Sync to base class" into main
2 parents f7f3b62 + f9f8330 commit 2d5ec07

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed
 

‎fs_mgr/libsnapshot/libsnapshot_cow/writer_base.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,16 @@ std::unique_ptr<chromeos_update_engine::FileDescriptor> CowWriterBase::OpenFileD
191191
block_dev_size);
192192
}
193193

194+
bool CowWriterBase::Sync() {
195+
if (is_dev_null_) {
196+
return true;
197+
}
198+
if (fsync(fd_.get()) < 0) {
199+
PLOG(ERROR) << "fsync failed";
200+
return false;
201+
}
202+
return true;
203+
}
204+
194205
} // namespace snapshot
195206
} // namespace android

‎fs_mgr/libsnapshot/libsnapshot_cow/writer_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CowWriterBase : public ICowWriter {
3434
// If the given label is not found, Initialize will fail.
3535
virtual bool Initialize(std::optional<uint64_t> label = {}) = 0;
3636

37+
bool Sync();
3738
bool AddCopy(uint64_t new_block, uint64_t old_block, uint64_t num_blocks = 1) override;
3839
bool AddRawBlocks(uint64_t new_block_start, const void* data, size_t size) override;
3940
bool AddXorBlocks(uint32_t new_block_start, const void* data, size_t size, uint32_t old_block,

‎fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -704,17 +704,6 @@ bool CowWriterV2::WriteRawData(const void* data, const size_t size) {
704704
return true;
705705
}
706706

707-
bool CowWriterV2::Sync() {
708-
if (is_dev_null_) {
709-
return true;
710-
}
711-
if (fsync(fd_.get()) < 0) {
712-
PLOG(ERROR) << "fsync failed";
713-
return false;
714-
}
715-
return true;
716-
}
717-
718707
bool CowWriterV2::Truncate(off_t length) {
719708
if (is_dev_null_ || is_block_device_) {
720709
return true;

‎fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class CowWriterV2 : public CowWriterBase {
5858
bool FlushCluster();
5959

6060
bool CompressBlocks(size_t num_blocks, const void* data);
61-
bool Sync();
6261
bool Truncate(off_t length);
6362
bool EnsureSpaceAvailable(const uint64_t bytes_needed) const;
6463

0 commit comments

Comments
 (0)
This repository has been archived.