Flush block device with ioctl before reading it back

This commit is contained in:
Imbus 2026-02-07 17:24:16 +01:00
parent c08ee6a738
commit 13e27bbcc1

View file

@ -11,6 +11,11 @@
#include <sys/stat.h>
#include <unistd.h>
#if __linux__
#include <linux/fs.h> /* IOTCL flush number */
#include <sys/ioctl.h> /* IOCTL */
#endif
#ifndef GITREV
#define GITREV "unknown"
#endif
@ -142,6 +147,9 @@ int perform_write(write_job_t *job) {
memset(job->buffer, 0, BLOCKSIZE);
memset(job->buffer2, 0, BLOCKSIZE);
/* This is essentially $ blockdev --flushbufs */
ioctl(block_fd, BLKFLSBUF);
int crc_back = crc32_init();
b_written = 0;