rem: run.start = HOST_ENDIAN_TO_BFS_INT16(run.Start() + ((pos - offset) >> blockShift)); run.length = HOST_ENDIAN_TO_BFS_INT16(run.Length() - ((pos - offset) >> blockShift));
add: run.start += (pos - offset) >> blockShift; run.length -= (pos - offset) >> blockShift;
context: Stream::ReadAt(off_t pos, uint8 *buffer, size_t *_length){	// set/check boundaries for pos/length	if (pos < 0)		return B_BAD_VALUE;	if (pos >= data.Size()) {		*_length = 0;		return B_NO_ERROR;	}	size_t length = *_length;	if (pos + length > data.Size())		length = data.Size() - pos;	block_run run;	off_t offset;	if (FindBlockRun(pos, run, offset) < B_OK) {		*_length = 0;		return B_BAD_VALUE;	}	uint32 bytesRead = 0;	uint32 blockSize = fVolume.BlockSize();	uint32 blockShift = fVolume.BlockShift();	uint8 *block;	// the first block_run we read could not be aligned to the block_size boundary	// (read partial block at the beginning)	// pos % block_size == (pos - offset) % block_size, offset % block_size == 0	if (pos % blockSize != 0) {		run.start = HOST_ENDIAN_TO_BFS_INT16(run.Start() + ((pos - offset) >> blockShift));		run.length = HOST_ENDIAN_TO_BFS_INT16(run.Length() - ((pos - offset) >> blockShift));		CachedBlock cached(fVolume, run);		if ((block = cached.Block()) == NULL) {			*_length = 0;			return B_BAD_VALUE;		}		bytesRead = blockSize - (pos % blockSize);		if (length < bytesRead)			bytesRead = length;		memcpy(buffer, block + (pos % blockSize), bytesRead);		pos += bytesRead;		length -= bytesRead;		if (length == 0) {			*_length = bytesRead;			return B_OK;		}		if (FindBlockRun(pos, run, offset) < B_OK) {			*_length = bytesRead;			return B_BAD_VALUE;		}	}	// the first block_run is already filled in at this point	// read the following complete blocks using cached_read(),	// the last partial block is read using the generic Cache class	bool partial = false;	while (length > 0) {		// offset is the offset to the current pos in the block_run		run.start = HOST_ENDIAN_TO_BFS_INT16(run.Start() + ((pos - offset) >> blockShift));		run.length = HOST_ENDIAN_TO_BFS_INT16(run.Length() - ((pos - offset) >> blockShift));		if (uint32(run.Length() << blockShift) > length) {			if (length < blockSize) {				CachedBlock cached(fVolume, run);				if ((block = cached.Block()) == NULL) {					*_length = bytesRead;					return B_BAD_VALUE;				}				memcpy(buffer + bytesRead, block, length);				bytesRead += length;				break;			}			run.length = HOST_ENDIAN_TO_BFS_INT16(length >> blockShift);			partial = true;		}		if (read_pos(fVolume.Device(), fVolume.ToOffset(run), buffer + bytesRead, run.Length() << fVolume.BlockShift()) < B_OK) {			*_length = bytesRead;			return B_BAD_VALUE;		}		int32 bytes = run.Length() << blockShift;		length -= bytes;		bytesRead += bytes;		if (length == 0)			break;		pos += bytes;		if (partial) {			// if the last block was read only partially, point block_run			// to the remaining part			run.start = HOST_ENDIAN_TO_BFS_INT16(run.Start() + run.Length());			run.length = 1;			offset = pos;		} else if (FindBlockRun(pos, run, offset) < B_OK) {			*_length = bytesRead;			return B_BAD_VALUE;		}	}	*_length = bytesRead;	return B_NO_ERROR;}