3 int read_in_full(int fd, void *buf, size_t count)
10 loaded = xread(fd, p, count);
25 void read_or_die(int fd, void *buf, size_t count)
29 loaded = read_in_full(fd, buf, count);
31 die("unexpected end of file");
33 die("read error (%s)", strerror(errno));
36 void write_or_die(int fd, const void *buf, size_t count)
42 written = xwrite(fd, p, count);
45 else if (written < 0) {
48 die("write error (%s)", strerror(errno));
55 int write_in_full(int fd, const void *buf, size_t count)
62 wcount = xwrite(fd, p, count);
77 int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
81 written = write_in_full(fd, buf, count);
83 fprintf(stderr, "%s: disk full?\n", msg);
86 else if (written < 0) {
89 fprintf(stderr, "%s: write error (%s)\n",
90 msg, strerror(errno));
97 int write_or_whine(int fd, const void *buf, size_t count, const char *msg)
101 written = write_in_full(fd, buf, count);
103 fprintf(stderr, "%s: disk full?\n", msg);
106 else if (written < 0) {
107 fprintf(stderr, "%s: write error (%s)\n",
108 msg, strerror(errno));