Skip to content

Commit

Permalink
f3read: report errors coming from fdatasync()
Browse files Browse the repository at this point in the history
Errors coming from fdatasync() are unexpected, but according to
issue #211 they happen.
This patch just reports the error and general guidance to users.
  • Loading branch information
AltraMayor committed Sep 4, 2023
1 parent 964ae86 commit 6609119
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion f3read.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,15 @@ static void validate_file(const char *path, int number, struct flow *fw,
* even when testing small memory cards without a remount, and
* we should have a better reading-speed measurement.
*/
assert(!fdatasync(fd));
if (fdatasync(fd) < 0) {
int saved_errno = errno;
/* The issue https://github.com/AltraMayor/f3/issues/211
* motivated the warning below.
*/
printf("\nWARNING:\nThe operating system returned errno=%i for fdatasync(): %s\nThis error is unexpected and you may find more information on the log of the kernel (e.g. command dmesg(1) on Linux).\n\n",
saved_errno, strerror(saved_errno));
exit(saved_errno);
}
assert(!posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED));

/* Help the kernel to help us. */
Expand Down

0 comments on commit 6609119

Please sign in to comment.