{
ssize_t loaded;
+ if (!count)
+ return;
loaded = read_in_full(fd, buf, count);
if (loaded == 0)
die("unexpected end of file");
{
const char *p = buf;
ssize_t total = 0;
- ssize_t written = 0;
while (count > 0) {
- written = xwrite(fd, p, count);
- if (written <= 0) {
- if (total)
- return total;
- else
- return written;
+ size_t written = xwrite(fd, p, count);
+ if (written < 0)
+ return -1;
+ if (!written) {
+ errno = ENOSPC;
+ return -1;
}
count -= written;
p += written;
{
ssize_t written;
+ if (!count)
+ return;
written = write_in_full(fd, buf, count);
if (written == 0)
die("disk full?");
{
ssize_t written;
+ if (!count)
+ return 1;
written = write_in_full(fd, buf, count);
if (written == 0) {
fprintf(stderr, "%s: disk full?\n", msg);
{
ssize_t written;
+ if (!count)
+ return 1;
written = write_in_full(fd, buf, count);
if (written == 0) {
fprintf(stderr, "%s: disk full?\n", msg);