* Actually include an offset to write to in writev_port_etc(). It would
previously just always write over the beginning of the buffer for each vector. Since the writev version isn't exposed to userland by means of a syscall and kernel internally nobody used it, nobody noticed so far. * Merge the two loops for user and kernel copy to remove the code duplication. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cd3e02ca1e
commit
2b86134925
@ -1434,38 +1434,27 @@ writev_port_etc(port_id id, int32 msgCode, const iovec* msgVecs,
|
||||
message->sender_team = team_get_current_team_id();
|
||||
|
||||
if (bufferSize > 0) {
|
||||
uint32 i;
|
||||
if (userCopy) {
|
||||
// copy from user memory
|
||||
for (i = 0; i < vecCount; i++) {
|
||||
size_t bytes = msgVecs[i].iov_len;
|
||||
if (bytes > bufferSize)
|
||||
bytes = bufferSize;
|
||||
size_t offset = 0;
|
||||
for (uint32 i = 0; i < vecCount; i++) {
|
||||
size_t bytes = msgVecs[i].iov_len;
|
||||
if (bytes > bufferSize)
|
||||
bytes = bufferSize;
|
||||
|
||||
status_t status = user_memcpy(message->buffer,
|
||||
if (userCopy) {
|
||||
status_t status = user_memcpy(message->buffer + offset,
|
||||
msgVecs[i].iov_base, bytes);
|
||||
if (status != B_OK) {
|
||||
put_port_message(message);
|
||||
goto error;
|
||||
}
|
||||
} else
|
||||
memcpy(message->buffer + offset, msgVecs[i].iov_base, bytes);
|
||||
|
||||
bufferSize -= bytes;
|
||||
if (bufferSize == 0)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// copy from kernel memory
|
||||
for (i = 0; i < vecCount; i++) {
|
||||
size_t bytes = msgVecs[i].iov_len;
|
||||
if (bytes > bufferSize)
|
||||
bytes = bufferSize;
|
||||
bufferSize -= bytes;
|
||||
if (bufferSize == 0)
|
||||
break;
|
||||
|
||||
memcpy(message->buffer, msgVecs[i].iov_base, bytes);
|
||||
|
||||
bufferSize -= bytes;
|
||||
if (bufferSize == 0)
|
||||
break;
|
||||
}
|
||||
offset += bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user