summaryrefslogtreecommitdiff
path: root/libfec
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2022-12-06 09:57:20 -0800
committerKelvin Zhang <zhangkelvin@google.com>2022-12-06 10:47:27 -0800
commit66ca49d58e69ad700943c5058f69b9c11db757cc (patch)
treead10241438a422f16b0b2ba0712bb4662c5d4c89 /libfec
parentf96ce5f411f6e9745bec01c66946f3056d6a45d5 (diff)
downloadextras-66ca49d58e69ad700943c5058f69b9c11db757cc.tar.gz
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
Diffstat (limited to 'libfec')
-rw-r--r--libfec/fec_read.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libfec/fec_read.cpp b/libfec/fec_read.cpp
index 889f990d..28a7c898 100644
--- a/libfec/fec_read.cpp
+++ b/libfec/fec_read.cpp
@@ -325,8 +325,12 @@ static ssize_t verity_read(fec_handle *f, uint8_t *dest, size_t count,
/* 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))) {