Skip to content

Commit

Permalink
test: Use fsync before/after reads/writes
Browse files Browse the repository at this point in the history
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
  • Loading branch information
francois-berder committed Apr 11, 2024
1 parent 9e2f599 commit bf9bfb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/linux_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ int linux_read(void *buffer, uint32_t length)
if (length == 0)
return 0;

fsync(fileno(image));

if (fread(buffer, sizeof(uint8_t), length, image) != length) {
printf("linux_read: Error while reading %u bytes\n", length);
return -1;
Expand Down Expand Up @@ -100,7 +102,9 @@ int linux_write(const void *buffer, uint32_t length)
return -1;
}

return fflush(image);
fsync(fileno(image));

return 0;
}

struct storage_dev_t linux_dev = {
Expand Down

0 comments on commit bf9bfb3

Please sign in to comment.