From 5154dc529f4cd85ba7439e5e875c52ea690954b3 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 21 Feb 2019 02:28:36 +0300 Subject: [PATCH] Bigger bug O_o --- era_copy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/era_copy.c b/era_copy.c index ff8a9d2..745520c 100644 --- a/era_copy.c +++ b/era_copy.c @@ -8,6 +8,7 @@ * License: GNU GPLv3.0 or later */ +#define _GNU_SOURCE #define _LARGEFILE64_SOURCE #include #include @@ -122,7 +123,8 @@ void era_copy(char *src_path, int era_block_size, int print_progress) int src = -1; if (src_path != NULL) { - src = open(src_path, O_RDONLY|O_LARGEFILE); + // dm-era device may return incorrect data when used without O_DIRECT O_o + src = open(src_path, O_RDONLY|O_LARGEFILE|O_DIRECT); if (src < 0) { fprintf(stderr, "Failed to open %s for reading: %s\n", src_path, strerror(errno));