Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a814ee6

Browse files
author
George Wright
committed
Implement WriteAtomically using write/fsync on all platforms, and enable
file unittests on Fuchsia
1 parent 7eb6ffe commit a814ee6

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

fml/platform/posix/file_posix.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,12 @@ bool WriteAtomically(const fml::UniqueFD& base_directory,
206206
return false;
207207
}
208208

209-
FileMapping mapping(temp_file, {FileMapping::Protection::kWrite});
210-
if (mapping.GetMutableMapping() == nullptr ||
211-
data.GetSize() != mapping.GetSize()) {
209+
ssize_t size = ::write(temp_file.get(), data.GetMapping(), data.GetSize());
210+
if (size == -1) {
212211
return false;
213212
}
214213

215-
::memcpy(mapping.GetMutableMapping(), data.GetMapping(), data.GetSize());
216-
217-
if (::msync(mapping.GetMutableMapping(), data.GetSize(), MS_SYNC) != 0) {
214+
if (::fsync(temp_file.get()) != 0) {
218215
return false;
219216
}
220217

testing/fuchsia/run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ echo "$(date) START:fml_tests ---------------------------------------"
9191
./fuchsia_ctl -d $device_name test \
9292
-f fml_tests-0.far \
9393
-t fml_tests \
94-
-a "--gtest_filter=-MessageLoop*:Message*:FileTest*" \
94+
-a "--gtest_filter=-MessageLoop*:Message*" \
9595
--identity-file $pkey \
9696
--timeout-seconds 300 \
9797
--packages-directory packages

0 commit comments

Comments
 (0)