Git development
 help / color / mirror / Atom feed
* [PATCH] write_sha1_buffer
@ 2005-04-16  0:50 Morten Welinder
  2005-04-16  2:55 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Morten Welinder @ 2005-04-16  0:50 UTC (permalink / raw)
  To: git, torvalds

This write will failing sooner or later when someone's disk fills up. 
That'll leave someone with
a truncated file.

Signed-off-by: Morten Welinder <mwelinder@gmail.com>


--- read-cache.c
+++ read-cache.c        2005-04-15 20:32:52.111187168 -0400
@@ -276,9 +276,13 @@
                                        " This is bad, bad, BAD!\a\n");
                return 0;
        }
-       write(fd, buf, size);
-       close(fd);
-       return 0;
+
+       if (write(fd, buf, size) != size) {
+               close(fd);
+               return error("Failed to write file %s\n", filename);
+       }
+
+       return close(fd);
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-04-16  2:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-16  0:50 [PATCH] write_sha1_buffer Morten Welinder
2005-04-16  2:55 ` Linus Torvalds
2005-04-16  2:59   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox