Skip to content

Verify copied destination file using direct I/O

Brian Tarricone requested to merge kelnos/thunar:file-verify-direct-io into master

After writing a destination file in a copy, the file (or at least parts of it) will likely still be in the OS's buffer cache. This means that when we read it back to compare it with the source, we're just comparing with what's in memory, not with what's on disk.

On Linux, we can use O_DIRECT when opening the file in order to bypass the buffer cache. Other OS-specific code will have to be added in order to support stronger verification on non-Linux OSes.

This code path is only used when the destination GFile has a file:// URI, as we can't open files this way when using any of GIO's/GVFS's other URI-scheme backends. Note that, even if opening with O_DIRECT succeeds, this is no guarantee that we are actually getting back the bytes that are on the disk. Some disks may "lie" that they've flushed all data and instead return cached data. Some filesystems -- especially network filesystems -- may return cached data.

Closes #1471 (closed)

Merge request reports