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:
Ingo Weinhold 2009-11-19 16:19:59 +00:00
parent 46cac7f7dd
commit 778aa3bf62

View File

@ -13,22 +13,24 @@
static status_t
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;
}
// lock the request buffer memory, if it is user memory
IOBuffer* ioBuffer = request->Buffer();
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)
return error;
}
// read/write
off_t offset = request->Offset() + request->TransferredBytes();
status_t error = isWrite
status_t error = writeToRequest
? request->CopyData(buffer, offset, size)
: request->CopyData(offset, buffer, size);
if (error != B_OK)