- if (!inplace || offset != offset2) {
- if (fd != -1 && write_file(fd, map, len) != (int)len) {
- rsyserr(FERROR, errno, "write failed on %s",
- full_fname(fname));
- exit_cleanup(RERR_FILEIO);
- }
- } else {
- flush_write_file(fd);
- if (do_lseek(fd,(OFF_T)len,SEEK_CUR) != offset+len) {
- rprintf(FERROR, "lseek failed on %s: %s, %lli, %lli, %i\n",
- full_fname(fname), strerror(errno),
- do_lseek(fd, 0, SEEK_CUR),
- offset + len, i);
- exit_cleanup(RERR_FILEIO);
+ if (inplace) {
+ if (offset == offset2 && fd != -1) {
+ if (flush_write_file(fd) < 0)
+ goto report_write_error;
+ offset += len;
+ if (do_lseek(fd, len, SEEK_CUR) != offset) {
+ rsyserr(FERROR, errno,
+ "lseek failed on %s",
+ full_fname(fname));
+ exit_cleanup(RERR_FILEIO);
+ }
+ continue;