Allow libfec to correct bad blocks
dm-verity already corrects I/O errors. userspace library libfec should
behave in the same way. This allows us to correct more errors during
OTA.
Test: th
Bug: 259622792
Change-Id: I0e53d7ff47474524f12c6a2abd901f55ed927137
diff --git a/libfec/fec_read.cpp b/libfec/fec_read.cpp
index 889f990..28a7c89 100644
--- a/libfec/fec_read.cpp
+++ b/libfec/fec_read.cpp
@@ -325,8 +325,12 @@
/* copy raw data without error correction */
if (!raw_pread(f->fd, data, FEC_BLOCKSIZE, curr_offset)) {
- error("failed to read: %s", strerror(errno));
- return -1;
+ if (errno == EIO) {
+ warn("I/O error encounter when reading, attempting to recover using fec");
+ } else {
+ error("failed to read: %s", strerror(errno));
+ return -1;
+ }
}
if (likely(f->hashtree().check_block_hash_with_index(curr, data))) {