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
)
31 loaded
= read_in_full(fd
, buf
, count
);
33 die("unexpected end of file");
35 die("read error (%s)", strerror(errno
));
38 int write_in_full(int fd
, const void *buf
, size_t count
)
44 size_t written
= xwrite(fd
, p
, count
);
59 void write_or_die(int fd
, const void *buf
, size_t count
)
65 written
= write_in_full(fd
, buf
, count
);
68 else if (written
< 0) {
71 die("write error (%s)", strerror(errno
));
75 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
)
103 written
= write_in_full(fd
, buf
, count
);
105 fprintf(stderr
, "%s: disk full?\n", msg
);
108 else if (written
< 0) {
109 fprintf(stderr
, "%s: write error (%s)\n",
110 msg
, strerror(errno
));