summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2007-01-11 21:04:11 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-01-11 21:19:18 (GMT)
commitf6aa66cb959393b6605a3288a3080d92d0983d78 (patch)
tree66811d1ac2f8343498b8028b76b5a8f8a2f500be
parentd145144c3ba050a1a8c8296f337b77a18500af00 (diff)
downloadgit-f6aa66cb959393b6605a3288a3080d92d0983d78.zip
git-f6aa66cb959393b6605a3288a3080d92d0983d78.tar.gz
git-f6aa66cb959393b6605a3288a3080d92d0983d78.tar.bz2
write_in_full: really write in full or return error on disk full.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--write_or_die.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/write_or_die.c b/write_or_die.c
index a119e1d..7f99a22 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;