From: Linus Torvalds Date: Thu, 11 Jan 2007 21:04:11 +0000 (-0800) Subject: write_in_full: really write in full or return error on disk full. X-Git-Tag: v1.5.0-rc1~12 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f6aa66cb959393b6605a3288a3080d92d0983d78;p=git.git write_in_full: really write in full or return error on disk full. Signed-off-by: Junio C Hamano --- diff --git a/write_or_die.c b/write_or_die.c index a119e1d20..7f99a22ae 100644 --- a/write_or_die.c +++ b/write_or_die.c @@ -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;