transfer_io_request_data(): There was some confusion about the isWrite
parameter and request->IsWrite(). The parameter means whether we want to write to the request's I/O buffer (therefore renamed it to writeToRequest), while request->IsWrite() indicates whether the request is a write request. One can only write to a read request's buffer and vice versa. IOBuffer::LockMemory() also wants to know whether the request is a write request, not whether we want to write to the memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34135 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,22 +13,24 @@
|
|||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
transfer_io_request_data(io_request* request, void* buffer, size_t size,
|
transfer_io_request_data(io_request* request, void* buffer, size_t size,
|
||||||
bool isWrite)
|
bool writeToRequest)
|
||||||
{
|
{
|
||||||
if (isWrite != request->IsWrite() || request->RemainingBytes() < size)
|
if (writeToRequest == request->IsWrite()
|
||||||
|
|| request->RemainingBytes() < size) {
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
// lock the request buffer memory, if it is user memory
|
// lock the request buffer memory, if it is user memory
|
||||||
IOBuffer* ioBuffer = request->Buffer();
|
IOBuffer* ioBuffer = request->Buffer();
|
||||||
if (ioBuffer->IsUser() && !ioBuffer->IsMemoryLocked()) {
|
if (ioBuffer->IsUser() && !ioBuffer->IsMemoryLocked()) {
|
||||||
status_t error = ioBuffer->LockMemory(request->Team(), isWrite);
|
status_t error = ioBuffer->LockMemory(request->Team(), !writeToRequest);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read/write
|
// read/write
|
||||||
off_t offset = request->Offset() + request->TransferredBytes();
|
off_t offset = request->Offset() + request->TransferredBytes();
|
||||||
status_t error = isWrite
|
status_t error = writeToRequest
|
||||||
? request->CopyData(buffer, offset, size)
|
? request->CopyData(buffer, offset, size)
|
||||||
: request->CopyData(offset, buffer, size);
|
: request->CopyData(offset, buffer, size);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user