summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-02 05:00:43 +0100
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-02 05:00:43 +0100
commita69625bf27f551d74a060fbdb69aa7cf7a6a2c32 (patch)
tree23c01d7ca33c930ab8a7ed7daebe1aefc1fee921
parentSnap for 8228195 from 8fbe9740ae37ce949503fd970bab1c702bef5d20 to udc-release (diff)
parentMerge "Fix non-ab fuse ota fail bug" am: 13907aef6b am: 3024caac9a am: 7c3d40f7c7 am: 1f8cb01c69 am: 52135ba155 (diff)
downloadandroid_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.tar
android_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.tar.gz
android_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.tar.bz2
android_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.tar.lz
android_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.tar.xz
android_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.tar.zst
android_bootable_recovery-a69625bf27f551d74a060fbdb69aa7cf7a6a2c32.zip
-rw-r--r--fuse_sideload/fuse_provider.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/fuse_sideload/fuse_provider.cpp b/fuse_sideload/fuse_provider.cpp
index 8fa1b5c2e..2183d0844 100644
--- a/fuse_sideload/fuse_provider.cpp
+++ b/fuse_sideload/fuse_provider.cpp
@@ -118,11 +118,16 @@ bool FuseBlockDataProvider::ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch
}
if (uint64_t tailing_bytes = fetch_size % source_block_size_; tailing_bytes != 0) {
- // Calculate the offset to last partial block.
+ // Calculate the offset to last partial block. Two possibilities as below:
+ // 1: fetch_size < source_block_size_, the read_ranges is a blank range_set.
+ // Get the last block num through GetBlockNumber() of the offset block.
+ // 2: fetch_size >= source_block_size_, the last block num is already stored
+ // in read-ranges by GetSubRanges() above.
uint64_t tailing_offset =
read_ranges.value()
? static_cast<uint64_t>((read_ranges->cend() - 1)->second) * source_block_size_
- : static_cast<uint64_t>(start_block) * source_block_size_;
+ : static_cast<uint64_t>(ranges_.GetBlockNumber(offset / source_block_size_)) *
+ source_block_size_;
if (!android::base::ReadFullyAtOffset(fd_, next_out, tailing_bytes, tailing_offset)) {
PLOG(ERROR) << "Failed to read tailing " << tailing_bytes << " bytes at offset "
<< tailing_offset;