From f6aa66cb959393b6605a3288a3080d92d0983d78 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 11 Jan 2007 13:04:11 -0800 Subject: [PATCH] write_in_full: really write in full or return error on disk full. Signed-off-by: Junio C Hamano --- write_or_die.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/write_or_die.c b/write_or_die.c index a119e1d208..7f99a22aed 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;