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
)
42 size_t written
= xwrite(fd
, p
, count
);
57 void write_or_die(int fd
, const void *buf
, size_t count
)
61 written
= write_in_full(fd
, buf
, count
);
64 else if (written
< 0) {
67 die("write error (%s)", strerror(errno
));
71 int write_or_whine_pipe(int fd
, const void *buf
, size_t count
, const char *msg
)
75 written
= write_in_full(fd
, buf
, count
);
77 fprintf(stderr
, "%s: disk full?\n", msg
);
80 else if (written
< 0) {
83 fprintf(stderr
, "%s: write error (%s)\n",
84 msg
, strerror(errno
));
91 int write_or_whine(int fd
, const void *buf
, size_t count
, const char *msg
)
95 written
= write_in_full(fd
, buf
, count
);
97 fprintf(stderr
, "%s: disk full?\n", msg
);
100 else if (written
< 0) {
101 fprintf(stderr
, "%s: write error (%s)\n",
102 msg
, strerror(errno
));