Code

write_in_full: really write in full or return error on disk full.
authorLinus Torvalds <torvalds@osdl.org>
Thu, 11 Jan 2007 21:04:11 +0000 (13:04 -0800)
committerJunio C Hamano <junkio@cox.net>
Thu, 11 Jan 2007 21:19:18 +0000 (13:19 -0800)
Signed-off-by: Junio C Hamano <junkio@cox.net>
write_or_die.c

index a119e1d208445093dd1d2869729eca9435aa020e..7f99a22aed43afd8ca06d3eafef8d3e836b15107 100644 (file)
@@ -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;