Skip to content

Commit c4c1f4e

Browse files
jeckersballisonkarlitskaya
authored andcommitted
fsverity: call sync_data (fdatasync) in test code
This partially fixes #106. There's a race between the read-write file descriptor being closed, and the subsequent ioctl to enable fsverify on the read-only copy. Sometimes the ioctl will return ETXTBSY. Syncing the data here seems to be sufficient to resolve this race, but *only* on ext4. On btrfs, this is not sufficient. I *can* fix this on btrfs by doing a `syncfs()`, but we are trying to avoid doing that here. Signed-off-by: John Eckersberg <[email protected]>
1 parent 821eeae commit c4c1f4e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/fsverity/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ mod tests {
181181
fn rdonly_file_with(data: &[u8]) -> OwnedFd {
182182
let mut file = tempfile();
183183
file.write_all(data).unwrap();
184+
file.sync_data().unwrap();
184185
let fd = open(
185186
proc_self_fd(&file),
186187
OFlags::RDONLY | OFlags::CLOEXEC,

0 commit comments

Comments
 (0)