for (i=0;i<count;i++) {
int n1 = MIN(len,n);
+ char *map = map_ptr(buf,offset,n1);
- s->sums[i].sum1 = get_checksum1(buf,n1);
- get_checksum2(buf,n1,s->sums[i].sum2);
+ s->sums[i].sum1 = get_checksum1(map,n1);
+ get_checksum2(map,n1,s->sums[i].sum2);
s->sums[i].offset = offset;
s->sums[i].len = n1;
i,(int)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1);
len -= n1;
- buf += n1;
offset += n1;
}
#endif
#ifdef HAVE_MKNOD
- if (preserve_devices &&
- (S_ISCHR(flist->files[i].mode) || S_ISBLK(flist->files[i].mode))) {
+ if (preserve_devices && IS_DEVICE(flist->files[i].mode)) {
if (statret != 0 ||
st.st_mode != flist->files[i].mode ||
st.st_rdev != flist->files[i].dev) {
if (st.st_size > 0) {
buf = map_file(fd,st.st_size);
- if (!buf) {
- fprintf(stderr,"mmap : %s\n",strerror(errno));
- close(fd);
- return;
- }
} else {
buf = NULL;
}
fprintf(stderr,"chunk[%d] of size %d at %d offset=%d\n",
i,len,(int)offset2,(int)offset);
- if (write(fd,buf+offset2,len) != len) {
+ if (write(fd,map_ptr(buf,offset2,len),len) != len) {
fprintf(stderr,"write failed on %s : %s\n",fname,strerror(errno));
exit(1);
}
char *dot=".";
int i;
+ if (!am_server && cvs_exclude)
+ add_cvs_excludes();
if (!(local_file_list = send_file_list(-1,recurse,1,&dot)))
return;
static char *cleanup_fname = NULL;
-int sig_int(void)
+void sig_int(void)
{
if (cleanup_fname)
unlink(cleanup_fname);
char *buf;
int i;
- if (verbose > 2)
+ if (verbose > 2) {
fprintf(stderr,"recv_files(%d) starting\n",flist->count);
+ }
if (recurse && delete_mode && !local_name && flist->count>0) {
delete_files(flist);
fprintf(stderr,"recv_files(%s)\n",fname);
/* open the file */
- if ((fd1 = open(fname,O_RDONLY)) == -1 &&
- (fd1 = open(fname,O_RDONLY|O_CREAT,flist->files[i].mode)) == -1) {
- fprintf(stderr,"recv_files failed to open %s\n",fname);
- return -1;
- }
+ fd1 = open(fname,O_RDONLY);
- if (fstat(fd1,&st) != 0) {
+ if (fd1 != -1 && fstat(fd1,&st) != 0) {
fprintf(stderr,"fstat %s : %s\n",fname,strerror(errno));
close(fd1);
return -1;
}
- if (!S_ISREG(st.st_mode)) {
+ if (fd1 != -1 && !S_ISREG(st.st_mode)) {
fprintf(stderr,"%s : not a regular file\n",fname);
close(fd1);
return -1;
}
- if (st.st_size > 0) {
+ if (fd1 != -1 && st.st_size > 0) {
buf = map_file(fd1,st.st_size);
- if (!buf) {
- fprintf(stderr,"map_file failed\n");
- return -1;
- }
} else {
buf = NULL;
}
fprintf(stderr,"mktemp %s failed\n",fnametmp);
return -1;
}
- fd2 = open(fnametmp,O_WRONLY|O_CREAT,st.st_mode);
+ fd2 = open(fnametmp,O_WRONLY|O_CREAT,flist->files[i].mode);
if (fd2 == -1) {
fprintf(stderr,"open %s : %s\n",fnametmp,strerror(errno));
return -1;
/* recv file data */
receive_data(f_in,buf,fd2,fname);
- close(fd1);
+ if (fd1 != -1) {
+ unmap_file(buf,st.st_size);
+ close(fd1);
+ }
close(fd2);
if (verbose > 2)
if (make_backups) {
char fnamebak[MAXPATHLEN];
sprintf(fnamebak,"%s%s",fname,backup_suffix);
- if (rename(fname,fnamebak) != 0) {
+ if (rename(fname,fnamebak) != 0 && errno != ENOENT) {
fprintf(stderr,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
exit(1);
}
cleanup_fname = NULL;
- unmap_file(buf,st.st_size);
-
set_perms(fname,&flist->files[i],NULL,0);
}
if (verbose > 2)
fprintf(stderr,"send_files starting\n");
+ setup_nonblocking(f_in,f_out);
+
while (1)
{
i = read_int(f_in);
if (st.st_size > 0) {
buf = map_file(fd,st.st_size);
- if (!buf) {
- fprintf(stderr,"map_file failed : %s\n",strerror(errno));
- return -1;
- }
} else {
buf = NULL;
}