Flush block device with ioctl before reading it back
This commit is contained in:
parent
c08ee6a738
commit
13e27bbcc1
1 changed files with 8 additions and 0 deletions
|
|
@ -11,6 +11,11 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if __linux__
|
||||||
|
#include <linux/fs.h> /* IOTCL flush number */
|
||||||
|
#include <sys/ioctl.h> /* IOCTL */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GITREV
|
#ifndef GITREV
|
||||||
#define GITREV "unknown"
|
#define GITREV "unknown"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -142,6 +147,9 @@ int perform_write(write_job_t *job) {
|
||||||
memset(job->buffer, 0, BLOCKSIZE);
|
memset(job->buffer, 0, BLOCKSIZE);
|
||||||
memset(job->buffer2, 0, BLOCKSIZE);
|
memset(job->buffer2, 0, BLOCKSIZE);
|
||||||
|
|
||||||
|
/* This is essentially $ blockdev --flushbufs */
|
||||||
|
ioctl(block_fd, BLKFLSBUF);
|
||||||
|
|
||||||
int crc_back = crc32_init();
|
int crc_back = crc32_init();
|
||||||
b_written = 0;
|
b_written = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue