Implement WriteAtomically using write/fsync on all platforms, and enable (flutter/engine#18320)
This commit is contained in:
@@ -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));
|
||||
|
||||
if (written == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
remaining -= written;
|
||||
offset += written;
|
||||
}
|
||||
|
||||
::memcpy(mapping.GetMutableMapping(), data.GetMapping(), data.GetSize());
|
||||
|
||||
if (::msync(mapping.GetMutableMapping(), data.GetSize(), MS_SYNC) != 0) {
|
||||
if (::fsync(temp_file.get()) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"features": [
|
||||
"vulkan",
|
||||
"deprecated-ambient-replace-as-executable",
|
||||
"isolated-cache-storage"
|
||||
"isolated-cache-storage",
|
||||
"isolated-temp"
|
||||
],
|
||||
"services": [
|
||||
"fuchsia.accessibility.semantics.SemanticsManager",
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user