diff --git a/minix/drivers/system/log/log.c b/minix/drivers/system/log/log.c index caba7cf3d..ee4393a7b 100644 --- a/minix/drivers/system/log/log.c +++ b/minix/drivers/system/log/log.c @@ -126,7 +126,7 @@ subwrite(struct logdevice *log, size_t size, endpoint_t endpt, 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; @@ -134,6 +134,7 @@ subwrite(struct logdevice *log, size_t size, endpoint_t endpt, /* 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; @@ -147,8 +148,11 @@ subwrite(struct logdevice *log, size_t size, endpoint_t endpt, } 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); @@ -160,7 +164,7 @@ subwrite(struct logdevice *log, size_t size, endpoint_t endpt, 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) { @@ -185,7 +189,7 @@ subwrite(struct logdevice *log, size_t size, endpoint_t endpt, log->log_selected &= ~CDEV_OP_RD; } - return r; + return result; } /*===========================================================================*