version 1.121, 2005/04/02 12:41:16 |
version 1.122, 2005/05/24 17:32:43 |
|
|
struct stat stb; |
struct stat stb; |
static BUF buffer; |
static BUF buffer; |
BUF *bp; |
BUF *bp; |
off_t i, amt, result, statbytes; |
off_t i, amt, statbytes; |
|
size_t result; |
int fd, haderr, indx; |
int fd, haderr, indx; |
char *last, *name, buf[2048]; |
char *last, *name, buf[2048]; |
int len; |
int len; |
|
|
if (!haderr) { |
if (!haderr) { |
result = atomicio(read, fd, bp->buf, amt); |
result = atomicio(read, fd, bp->buf, amt); |
if (result != amt) |
if (result != amt) |
haderr = result >= 0 ? EIO : errno; |
haderr = errno; |
} |
} |
if (haderr) |
if (haderr) |
(void) atomicio(vwrite, remout, bp->buf, amt); |
(void) atomicio(vwrite, remout, bp->buf, amt); |
else { |
else { |
result = atomicio(vwrite, remout, bp->buf, amt); |
result = atomicio(vwrite, remout, bp->buf, amt); |
if (result != amt) |
if (result != amt) |
haderr = result >= 0 ? EIO : errno; |
haderr = errno; |
statbytes += result; |
statbytes += result; |
} |
} |
if (limit_rate) |
if (limit_rate) |
|
|
YES, NO, DISPLAYED |
YES, NO, DISPLAYED |
} wrerr; |
} wrerr; |
BUF *bp; |
BUF *bp; |
off_t i, j; |
off_t i; |
|
size_t j; |
int amt, count, exists, first, mask, mode, ofd, omode; |
int amt, count, exists, first, mask, mode, ofd, omode; |
off_t size, statbytes; |
off_t size, statbytes; |
int setimes, targisdir, wrerrno = 0; |
int setimes, targisdir, wrerrno = 0; |
|
|
targisdir = 1; |
targisdir = 1; |
for (first = 1;; first = 0) { |
for (first = 1;; first = 0) { |
cp = buf; |
cp = buf; |
if (atomicio(read, remin, cp, 1) <= 0) |
if (atomicio(read, remin, cp, 1) != 1) |
return; |
return; |
if (*cp++ == '\n') |
if (*cp++ == '\n') |
SCREWUP("unexpected <newline>"); |
SCREWUP("unexpected <newline>"); |
|
|
count += amt; |
count += amt; |
do { |
do { |
j = atomicio(read, remin, cp, amt); |
j = atomicio(read, remin, cp, amt); |
if (j <= 0) { |
if (j == 0) { |
run_err("%s", j ? strerror(errno) : |
run_err("%s", j ? strerror(errno) : |
"dropped connection"); |
"dropped connection"); |
exit(1); |
exit(1); |
|
|
if (count == bp->cnt) { |
if (count == bp->cnt) { |
/* Keep reading so we stay sync'd up. */ |
/* Keep reading so we stay sync'd up. */ |
if (wrerr == NO) { |
if (wrerr == NO) { |
j = atomicio(vwrite, ofd, bp->buf, count); |
if (atomicio(vwrite, ofd, bp->buf, |
if (j != count) { |
count) != count) { |
wrerr = YES; |
wrerr = YES; |
wrerrno = j >= 0 ? EIO : errno; |
wrerrno = errno; |
} |
} |
} |
} |
count = 0; |
count = 0; |
|
|
if (showprogress) |
if (showprogress) |
stop_progress_meter(); |
stop_progress_meter(); |
if (count != 0 && wrerr == NO && |
if (count != 0 && wrerr == NO && |
(j = atomicio(vwrite, ofd, bp->buf, count)) != count) { |
atomicio(vwrite, ofd, bp->buf, count) != count) { |
wrerr = YES; |
wrerr = YES; |
wrerrno = j >= 0 ? EIO : errno; |
wrerrno = errno; |
} |
} |
if (wrerr == NO && ftruncate(ofd, size) != 0) { |
if (wrerr == NO && ftruncate(ofd, size) != 0) { |
run_err("%s: truncate: %s", np, strerror(errno)); |
run_err("%s: truncate: %s", np, strerror(errno)); |