Skip to content

Commit

Permalink
write_in_full: really write in full or return error on disk full.
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Jan 11, 2007
1 parent d145144 commit f6aa66c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions write_or_die.c
Expand Up @@ -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;
Expand Down

0 comments on commit f6aa66c

Please sign in to comment.