summaryrefslogtreecommitdiff
path: root/write_or_die.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2007-01-11 13:04:11 -0800
committerJunio C Hamano <junkio@cox.net>2007-01-11 13:19:18 -0800
commitf6aa66cb959393b6605a3288a3080d92d0983d78 (patch)
tree66811d1ac2f8343498b8028b76b5a8f8a2f500be /write_or_die.c
parentd145144c3ba050a1a8c8296f337b77a18500af00 (diff)
downloadgit-f6aa66cb959393b6605a3288a3080d92d0983d78.tar.gz
write_in_full: really write in full or return error on disk full.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'write_or_die.c')
-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 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;