3 void read_or_die(int fd, void *buf, size_t count)
9 loaded = xread(fd, p, count);
11 die("unexpected end of file");
13 die("read error (%s)", strerror(errno));
19 void write_or_die(int fd, const void *buf, size_t count)
25 written = xwrite(fd, p, count);
28 else if (written < 0) {
31 die("write error (%s)", strerror(errno));
38 int write_in_full(int fd, const void *buf, size_t count)
45 wcount = xwrite(fd, p, count);
60 int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
64 written = write_in_full(fd, buf, count);
66 fprintf(stderr, "%s: disk full?\n", msg);
69 else if (written < 0) {
72 fprintf(stderr, "%s: write error (%s)\n",
73 msg, strerror(errno));
80 int write_or_whine(int fd, const void *buf, size_t count, const char *msg)
84 written = write_in_full(fd, buf, count);
86 fprintf(stderr, "%s: disk full?\n", msg);
89 else if (written < 0) {
90 fprintf(stderr, "%s: write error (%s)\n",
91 msg, strerror(errno));