diff options
Diffstat (limited to 'fuse_sideload')
-rw-r--r-- | fuse_sideload/fuse_provider.cpp | 9 | ||||
-rw-r--r-- | fuse_sideload/fuse_sideload.cpp | 2 |
2 files changed, 8 insertions, 3 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; diff --git a/fuse_sideload/fuse_sideload.cpp b/fuse_sideload/fuse_sideload.cpp index 3d9480309..07cbe96f3 100644 --- a/fuse_sideload/fuse_sideload.cpp +++ b/fuse_sideload/fuse_sideload.cpp @@ -225,7 +225,7 @@ static int handle_release(void* /* data */, fuse_data* /* fd */, const fuse_in_h // Fetch a block from the host into fd->curr_block and fd->block_data. // Returns 0 on successful fetch, negative otherwise. -static int fetch_block(fuse_data* fd, uint32_t block) { +static int fetch_block(fuse_data* fd, uint64_t block) { if (block == fd->curr_block) { return 0; } |