fix: use long to store the device size
This commit is contained in:
1 parent
32c2090e5b
commit
c984e79e95
3 files changed
+7
-7
No files matched your search
@@ -78,7 +78,7 @@ class BlockDeviceInputStream(
|
||||
* The size of the block device in bytes.
|
||||
*/
|
||||
private val sizeBytes: Long
|
||||
get() = blockDev.blocks.toLong() * blockDev.blockSize
|
||||
get() = blockDev.blocks * blockDev.blockSize.toLong()
|
||||
|
||||
/**
|
||||
* Whether the stream is at or past the end of the block device.
|
||||
@@ -198,7 +198,7 @@ class BlockDeviceInputStream(
|
||||
|
||||
while (true) {
|
||||
val blockNumber = mReadNextBlockNumber.getAndAdd(bufferBlocks)
|
||||
if (blockNumber !in 0 until blockDev.blocks) break
|
||||
if (blockNumber !in 0 until (blockDev.blocks.toLong() and 0xFFFFFFFFL)) break
|
||||
mInFlightBlockNumber.set(blockNumber)
|
||||
|
||||
traceIo("read $blockNumber buffer $bufferBlocks blocks start")
|
||||
@@ -259,7 +259,7 @@ class BlockDeviceInputStream(
|
||||
|
||||
if (newPosition == sizeBytes) {
|
||||
// EOF
|
||||
mCurrentBlockOffset = blockDev.blocks
|
||||
mCurrentBlockOffset = blockDev.blocks.toLong() and 0xFFFFFFFFL
|
||||
mReadBuffer = ByteBuffer.allocate(0)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -77,12 +77,12 @@ class BlockDeviceOutputStream(
|
||||
* The total size of the block device in bytes.
|
||||
*/
|
||||
private val mSizeBytes: Long
|
||||
get() = blockDev.blocks * blockDev.blockSize
|
||||
get() = blockDev.blocks * blockDev.blockSize.toLong()
|
||||
|
||||
/**
|
||||
* The buffer used to store the data before it is written to the block device.
|
||||
*/
|
||||
private var mByteBuffer = ByteBuffer.allocate(minOf(blockDev.blockSize * bufferBlocks, mSizeBytes).toInt())
|
||||
private var mByteBuffer = ByteBuffer.allocate(minOf((blockDev.blockSize.toLong() * bufferBlocks), mSizeBytes).toInt())
|
||||
|
||||
/**
|
||||
* Whether the stream position is at or past the end of the block device.
|
||||
|
||||
@@ -346,7 +346,7 @@ class WorkerService : LifecycleService() {
|
||||
var blockDev by lateInit<BlockDeviceDriver>()
|
||||
var rawSourceStream: InputStream? = null
|
||||
var currentOffset = offset
|
||||
var imageSize: Long = 0
|
||||
var imageSize = 0L
|
||||
|
||||
val coroScope = CoroutineScope(Dispatchers.IO)
|
||||
|
||||
@@ -366,7 +366,7 @@ class WorkerService : LifecycleService() {
|
||||
// Resume a few blocks earlier in case things went haywire earlier
|
||||
currentOffset = max(currentOffset - blockDev.blockSize * BUFFER_BLOCKS * 2, 0L)
|
||||
|
||||
val devSize = blockDev.blocks.toLong() * blockDev.blockSize
|
||||
val devSize: Long = blockDev.blocks * blockDev.blockSize.toLong()
|
||||
Telemetry.debug(
|
||||
"Device size: ${devSize.toHRSize(false)} " +
|
||||
"(block size: ${blockDev.blockSize.toHRSize(false)}, " +
|
||||
|
||||
Reference in new issue
Block a user