Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions fml/platform/posix/file_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,23 @@ bool WriteAtomically(const fml::UniqueFD& base_directory,
return false;
}

FileMapping mapping(temp_file, {FileMapping::Protection::kWrite});
if (mapping.GetMutableMapping() == nullptr ||
data.GetSize() != mapping.GetSize()) {
return false;
}
ssize_t remaining = data.GetSize();
ssize_t written = 0;
ssize_t offset = 0;

while (remaining > 0) {
written = FML_HANDLE_EINTR(
::write(temp_file.get(), data.GetMapping() + offset, remaining));

::memcpy(mapping.GetMutableMapping(), data.GetMapping(), data.GetSize());
if (written == -1) {
return false;
}

remaining -= written;
offset += written;
}

if (::msync(mapping.GetMutableMapping(), data.GetSize(), MS_SYNC) != 0) {
if (::fsync(temp_file.get()) != 0) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion testing/fuchsia/meta/fuchsia_test.cmx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"features": [
"vulkan",
"deprecated-ambient-replace-as-executable",
"isolated-cache-storage"
"isolated-cache-storage",
"isolated-temp"
],
"services": [
"fuchsia.accessibility.semantics.SemanticsManager",
Expand Down
2 changes: 1 addition & 1 deletion testing/fuchsia/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ echo "$(date) START:fml_tests ---------------------------------------"
./fuchsia_ctl -d $device_name test \
-f fml_tests-0.far \
-t fml_tests \
-a "--gtest_filter=-FileTest*" \
-a "--gtest_filter=-FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure" \
--identity-file $pkey \
--timeout-seconds $test_timeout_seconds \
--packages-directory packages
Expand Down