1#include "cache.h"
23
void write_or_die(int fd, const void *buf, size_t count)
4{
5const char *p = buf;
6ssize_t written;
78
while (count > 0) {
9written = xwrite(fd, p, count);
10if (written == 0)
11die("disk full?");
12else if (written < 0) {
13if (errno == EPIPE)
14exit(0);
15die("write error (%s)", strerror(errno));
16}
17count -= written;
18p += written;
19}
20}