Browse Source

write_in_full: really write in full or return error on disk full.

Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Linus Torvalds 18 years ago committed by Junio C Hamano
parent
commit
f6aa66cb95
  1. 13
      write_or_die.c

13
write_or_die.c

@ -37,15 +37,14 @@ int write_in_full(int fd, const void *buf, size_t count) @@ -37,15 +37,14 @@ int write_in_full(int fd, const void *buf, size_t count)
{
const char *p = buf;
ssize_t total = 0;
ssize_t written = 0;

while (count > 0) {
written = xwrite(fd, p, count);
if (written <= 0) {
if (total)
return total;
else
return written;
size_t written = xwrite(fd, p, count);
if (written < 0)
return -1;
if (!written) {
errno = ENOSPC;
return -1;
}
count -= written;
p += written;

Loading…
Cancel
Save