cp_grant_id_t grant, char *localbuf)
{
size_t count, offset;
- int overflow, r;
+ int overflow, r, result;
devminor_t minor;
char *buf;
message m;
/* With a sufficiently large input size, we might wrap around the ring buffer
* multiple times.
*/
+ result = 0;
for (offset = 0; offset < size; offset += count) {
count = size - offset;
}
else {
if((r=sys_safecopyfrom(endpt, grant, offset,
- (vir_bytes)buf, count)) != OK)
- break; /* do process partial write upon error */
+ (vir_bytes)buf, count)) != OK) {
+ /* return any partial success upon error */
+ result = (offset > 0) ? (int)offset : r;
+ break;
+ }
}
LOGINC(log->log_write, count);
LOGINC(log->log_read, overflow);
}
- r = offset; /* this will be the return value upon success */
+ result += (int)count;
}
if (log->log_size > 0 && log->log_source != NONE) {
log->log_selected &= ~CDEV_OP_RD;
}
- return r;
+ return result;
}
/*===========================================================================*