Merge branch 'js/c-merge-recursive'
[git.git] / write_or_die.c
blobab4cb8a69cd6e54c12dac647bb5af1df54fdf6c8
1 #include "cache.h"
3 void write_or_die(int fd, const void *buf, size_t count)
5 const char *p = buf;
6 ssize_t written;
8 while (count > 0) {
9 written = xwrite(fd, p, count);
10 if (written == 0)
11 die("disk full?");
12 else if (written < 0) {
13 if (errno == EPIPE)
14 exit(0);
15 die("write error (%s)", strerror(errno));
17 count -= written;
18 p += written;