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 int write_in_full(int fd
, const void *buf
, size_t count
)
43 written
= xwrite(fd
, p
, count
);
58 void write_or_die(int fd
, const void *buf
, size_t count
)
62 written
= write_in_full(fd
, buf
, count
);
65 else if (written
< 0) {
68 die("write error (%s)", strerror(errno
));
72 int write_or_whine_pipe(int fd
, const void *buf
, size_t count
, const char *msg
)
76 written
= write_in_full(fd
, buf
, count
);
78 fprintf(stderr
, "%s: disk full?\n", msg
);
81 else if (written
< 0) {
84 fprintf(stderr
, "%s: write error (%s)\n",
85 msg
, strerror(errno
));
92 int write_or_whine(int fd
, const void *buf
, size_t count
, const char *msg
)
96 written
= write_in_full(fd
, buf
, count
);
98 fprintf(stderr
, "%s: disk full?\n", msg
);
101 else if (written
< 0) {
102 fprintf(stderr
, "%s: write error (%s)\n",
103 msg
, strerror(errno
));