summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--qcow/src/qcow.rs6
-rw-r--r--seccomp/aarch64/block_device.policy2
-rw-r--r--seccomp/x86_64/block_device.policy4
3 files changed, 10 insertions, 2 deletions
diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs
index 4f1cf7b..2052545 100644
--- a/qcow/src/qcow.rs
+++ b/qcow/src/qcow.rs
@@ -394,6 +394,8 @@ impl QcowFile {
         let cluster_size: u64 = self.cluster_size;
         let new_cluster_address: u64 = (file_end + cluster_size - 1) & !self.cluster_mask;
         self.file.set_len(new_cluster_address + cluster_size)?;
+        // Ensure the length is set before meta-data is updated.
+        self.file.sync_all()?;
 
         Ok(new_cluster_address)
     }
@@ -405,6 +407,8 @@ impl QcowFile {
         let new_addr: u64 = self.append_new_cluster()?;
         // Save the new block to the table and mark it as used.
         write_u64_to_offset(&mut self.file, entry_addr, new_addr | CLUSTER_USED_FLAG)?;
+        // Ensure that the metadata update is commited before writing data.
+        self.file.sync_data()?;
         // The cluster refcount starts at one indicating it is used but doesn't need COW.
         self.set_cluster_refcount(new_addr, 1)?;
         Ok(new_addr)
@@ -531,7 +535,7 @@ impl Write for QcowFile {
     }
 
     fn flush(&mut self) -> std::io::Result<()> {
-        self.file.flush()
+        self.file.sync_all()
     }
 }
 
diff --git a/seccomp/aarch64/block_device.policy b/seccomp/aarch64/block_device.policy
index f4d5135..cb9dce2 100644
--- a/seccomp/aarch64/block_device.policy
+++ b/seccomp/aarch64/block_device.policy
@@ -6,7 +6,9 @@ close: 1
 dup: 1
 dup2: 1
 exit_group: 1
+fdatasync: 1
 fstat64: 1
+fsync: 1
 ftruncate64: 1
 futex: 1
 _llseek: 1
diff --git a/seccomp/x86_64/block_device.policy b/seccomp/x86_64/block_device.policy
index 22a6846..ec79413 100644
--- a/seccomp/x86_64/block_device.policy
+++ b/seccomp/x86_64/block_device.policy
@@ -6,7 +6,9 @@ close: 1
 dup: 1
 dup2: 1
 exit_group: 1
+fdatasync: 1
 fstat: 1
+fsync: 1
 ftruncate: 1
 futex: 1
 lseek: 1
@@ -34,4 +36,4 @@ prctl: arg0 == 15
 restart_syscall: 1
 epoll_create1: 1
 epoll_ctl: 1
-epoll_wait: 1
\ No newline at end of file
+epoll_wait: 1