Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
just a stub for now
[rsync/rsync.git]
/
rsync.c
diff --git
a/rsync.c
b/rsync.c
index
5f0cef6
..
9d3b1c5
100644
(file)
--- a/
rsync.c
+++ b/
rsync.c
@@
-72,50
+72,51
@@
static int delete_file(char *fname)
struct dirent *di;
char buf[MAXPATHLEN];
extern int force_delete;
struct dirent *di;
char buf[MAXPATHLEN];
extern int force_delete;
-
struct stat
st;
+
STRUCT_STAT
st;
int ret;
if (do_unlink(fname) == 0 || errno == ENOENT) return 0;
#if SUPPORT_LINKS
int ret;
if (do_unlink(fname) == 0 || errno == ENOENT) return 0;
#if SUPPORT_LINKS
- ret = lstat(fname, &st);
+ ret =
do_
lstat(fname, &st);
#else
#else
- ret = stat(fname, &st);
+ ret =
do_
stat(fname, &st);
#endif
if (ret) {
#endif
if (ret) {
-
f
printf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
+
r
printf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
return -1;
}
if (!S_ISDIR(st.st_mode)) {
return -1;
}
if (!S_ISDIR(st.st_mode)) {
-
f
printf(FERROR,"unlink(%s) : %s\n", fname, strerror(errno));
+
r
printf(FERROR,"unlink(%s) : %s\n", fname, strerror(errno));
return -1;
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
if (!force_delete || (errno != ENOTEMPTY && errno != EEXIST)) {
return -1;
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
if (!force_delete || (errno != ENOTEMPTY && errno != EEXIST)) {
-
f
printf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
+
r
printf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
return -1;
}
/* now we do a recsursive delete on the directory ... */
d = opendir(fname);
if (!d) {
return -1;
}
/* now we do a recsursive delete on the directory ... */
d = opendir(fname);
if (!d) {
-
f
printf(FERROR,"opendir(%s): %s\n",
+
r
printf(FERROR,"opendir(%s): %s\n",
fname,strerror(errno));
return -1;
}
for (di=readdir(d); di; di=readdir(d)) {
fname,strerror(errno));
return -1;
}
for (di=readdir(d); di; di=readdir(d)) {
- if (strcmp(di->d_name,".")==0 ||
- strcmp(di->d_name,"..")==0)
+ char *dname = d_name(di);
+ if (strcmp(dname,".")==0 ||
+ strcmp(dname,"..")==0)
continue;
continue;
- strncpy(buf, fname, (MAXPATHLEN-strlen(d
i->d_
name))-2);
+ strncpy(buf, fname, (MAXPATHLEN-strlen(dname))-2);
strcat(buf, "/");
strcat(buf, "/");
- strcat(buf, d
i->d_
name);
+ strcat(buf, dname);
buf[MAXPATHLEN-1] = 0;
if (verbose > 0)
buf[MAXPATHLEN-1] = 0;
if (verbose > 0)
-
f
printf(FINFO,"deleting %s\n", buf);
+
r
printf(FINFO,"deleting %s\n", buf);
if (delete_file(buf) != 0) {
closedir(d);
return -1;
if (delete_file(buf) != 0) {
closedir(d);
return -1;
@@
-125,7
+126,7
@@
static int delete_file(char *fname)
closedir(d);
if (do_rmdir(fname) != 0) {
closedir(d);
if (do_rmdir(fname) != 0) {
-
f
printf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
+
r
printf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
return -1;
}
return -1;
}
@@
-158,14
+159,14
@@
static void send_sums(struct sum_struct *s,int f_out)
generate approximately one checksum every n bytes
*/
generate approximately one checksum every n bytes
*/
-static struct sum_struct *generate_sums(struct map_struct *buf,
off_t
len,int n)
+static struct sum_struct *generate_sums(struct map_struct *buf,
OFF_T
len,int n)
{
int i;
struct sum_struct *s;
int count;
int block_len = n;
int remainder = (len%block_len);
{
int i;
struct sum_struct *s;
int count;
int block_len = n;
int remainder = (len%block_len);
-
off_t
offset = 0;
+
OFF_T
offset = 0;
count = (len+(block_len-1))/block_len;
count = (len+(block_len-1))/block_len;
@@
-183,7
+184,7
@@
static struct sum_struct *generate_sums(struct map_struct *buf,off_t len,int n)
}
if (verbose > 3)
}
if (verbose > 3)
-
f
printf(FINFO,"count=%d rem=%d n=%d flength=%d\n",
+
r
printf(FINFO,"count=%d rem=%d n=%d flength=%d\n",
s->count,s->remainder,s->n,(int)s->flength);
s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count);
s->count,s->remainder,s->n,(int)s->flength);
s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count);
@@
-201,7
+202,7
@@
static struct sum_struct *generate_sums(struct map_struct *buf,off_t len,int n)
s->sums[i].i = i;
if (verbose > 3)
s->sums[i].i = i;
if (verbose > 3)
-
f
printf(FINFO,"chunk[%d] offset=%d len=%d sum1=%08x\n",
+
r
printf(FINFO,"chunk[%d] offset=%d len=%d sum1=%08x\n",
i,(int)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1);
len -= n1;
i,(int)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1);
len -= n1;
@@
-219,7
+220,7
@@
static struct sum_struct *receive_sums(int f)
{
struct sum_struct *s;
int i;
{
struct sum_struct *s;
int i;
-
off_t
offset = 0;
+
OFF_T
offset = 0;
s = (struct sum_struct *)malloc(sizeof(*s));
if (!s) out_of_memory("receive_sums");
s = (struct sum_struct *)malloc(sizeof(*s));
if (!s) out_of_memory("receive_sums");
@@
-230,7
+231,7
@@
static struct sum_struct *receive_sums(int f)
s->sums = NULL;
if (verbose > 3)
s->sums = NULL;
if (verbose > 3)
-
f
printf(FINFO,"count=%d n=%d rem=%d\n",
+
r
printf(FINFO,"count=%d n=%d rem=%d\n",
s->count,s->n,s->remainder);
if (s->count == 0)
s->count,s->n,s->remainder);
if (s->count == 0)
@@
-254,7
+255,7
@@
static struct sum_struct *receive_sums(int f)
offset += s->sums[i].len;
if (verbose > 3)
offset += s->sums[i].len;
if (verbose > 3)
-
f
printf(FINFO,"chunk[%d] len=%d offset=%d sum1=%08x\n",
+
r
printf(FINFO,"chunk[%d] len=%d offset=%d sum1=%08x\n",
i,s->sums[i].len,(int)s->sums[i].offset,s->sums[i].sum1);
}
i,s->sums[i].len,(int)s->sums[i].offset,s->sums[i].sum1);
}
@@
-264,17
+265,17
@@
static struct sum_struct *receive_sums(int f)
}
}
-static int set_perms(char *fname,struct file_struct *file,
struct stat
*st,
+static int set_perms(char *fname,struct file_struct *file,
STRUCT_STAT
*st,
int report)
{
int updated = 0;
int report)
{
int updated = 0;
-
struct stat
st2;
+
STRUCT_STAT
st2;
if (dry_run) return 0;
if (!st) {
if (link_stat(fname,&st2) != 0) {
if (dry_run) return 0;
if (!st) {
if (link_stat(fname,&st2) != 0) {
-
f
printf(FERROR,"stat %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"stat %s : %s\n",fname,strerror(errno));
return 0;
}
st = &st2;
return 0;
}
st = &st2;
@@
-284,7
+285,7
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
st->st_mtime != file->modtime) {
updated = 1;
if (set_modtime(fname,file->modtime) != 0) {
st->st_mtime != file->modtime) {
updated = 1;
if (set_modtime(fname,file->modtime) != 0) {
-
f
printf(FERROR,"failed to set times on %s : %s\n",
+
r
printf(FERROR,"failed to set times on %s : %s\n",
fname,strerror(errno));
return 0;
}
fname,strerror(errno));
return 0;
}
@@
-295,7
+296,7
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
st->st_mode != file->mode) {
updated = 1;
if (do_chmod(fname,file->mode) != 0) {
st->st_mode != file->mode) {
updated = 1;
if (do_chmod(fname,file->mode) != 0) {
-
f
printf(FERROR,"failed to set permissions on %s : %s\n",
+
r
printf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
return 0;
}
fname,strerror(errno));
return 0;
}
@@
-310,7
+311,7
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
if (preserve_uid && st->st_uid != file->uid)
updated = 1;
if (verbose>1 || preserve_uid)
if (preserve_uid && st->st_uid != file->uid)
updated = 1;
if (verbose>1 || preserve_uid)
-
f
printf(FERROR,"chown %s : %s\n",
+
r
printf(FERROR,"chown %s : %s\n",
fname,strerror(errno));
return updated;
}
fname,strerror(errno));
return updated;
}
@@
-319,9
+320,9
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
if (verbose > 1 && report) {
if (updated)
if (verbose > 1 && report) {
if (updated)
-
f
printf(FINFO,"%s\n",fname);
+
r
printf(FINFO,"%s\n",fname);
else
else
-
f
printf(FINFO,"%s is uptodate\n",fname);
+
r
printf(FINFO,"%s is uptodate\n",fname);
}
return updated;
}
}
return updated;
}
@@
-329,7
+330,7
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
/* choose whether to skip a particular file */
static int skip_file(char *fname,
/* choose whether to skip a particular file */
static int skip_file(char *fname,
- struct file_struct *file,
struct stat
*st)
+ struct file_struct *file,
STRUCT_STAT
*st)
{
if (st->st_size != file->length) {
return 0;
{
if (st->st_size != file->length) {
return 0;
@@
-364,14
+365,14
@@
int adapt_block_size(struct file_struct *file, int bsize)
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
{
int fd;
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
{
int fd;
-
struct stat
st;
+
STRUCT_STAT
st;
struct map_struct *buf;
struct sum_struct *s;
int statret;
struct file_struct *file = flist->files[i];
if (verbose > 2)
struct map_struct *buf;
struct sum_struct *s;
int statret;
struct file_struct *file = flist->files[i];
if (verbose > 2)
-
f
printf(FINFO,"recv_generator(%s,%d)\n",fname,i);
+
r
printf(FINFO,"recv_generator(%s,%d)\n",fname,i);
statret = link_stat(fname,&st);
statret = link_stat(fname,&st);
@@
-379,7
+380,7
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (dry_run) return;
if (statret == 0 && !S_ISDIR(st.st_mode)) {
if (do_unlink(fname) != 0) {
if (dry_run) return;
if (statret == 0 && !S_ISDIR(st.st_mode)) {
if (do_unlink(fname) != 0) {
-
f
printf(FERROR,"unlink %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"unlink %s : %s\n",fname,strerror(errno));
return;
}
statret = -1;
return;
}
statret = -1;
@@
-388,12
+389,12
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname)==0 &&
do_mkdir(fname,file->mode)==0)) {
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname)==0 &&
do_mkdir(fname,file->mode)==0)) {
-
f
printf(FERROR,"mkdir %s : %s (2)\n",
+
r
printf(FERROR,"mkdir %s : %s (2)\n",
fname,strerror(errno));
}
}
if (set_perms(fname,file,NULL,0) && verbose)
fname,strerror(errno));
}
}
if (set_perms(fname,file,NULL,0) && verbose)
-
f
printf(FINFO,"%s/\n",fname);
+
r
printf(FINFO,"%s/\n",fname);
return;
}
return;
}
@@
-413,12
+414,12
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
}
delete_file(fname);
if (do_symlink(file->link,fname) != 0) {
}
delete_file(fname);
if (do_symlink(file->link,fname) != 0) {
-
f
printf(FERROR,"link %s -> %s : %s\n",
+
r
printf(FERROR,"link %s -> %s : %s\n",
fname,file->link,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose)
fname,file->link,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose)
-
f
printf(FINFO,"%s -> %s\n",
+
r
printf(FINFO,"%s -> %s\n",
fname,file->link);
}
#endif
fname,file->link);
}
#endif
@@
-432,14
+433,14
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
st.st_rdev != file->rdev) {
delete_file(fname);
if (verbose > 2)
st.st_rdev != file->rdev) {
delete_file(fname);
if (verbose > 2)
-
f
printf(FINFO,"mknod(%s,0%o,0x%x)\n",
+
r
printf(FINFO,"mknod(%s,0%o,0x%x)\n",
fname,(int)file->mode,(int)file->rdev);
if (do_mknod(fname,file->mode,file->rdev) != 0) {
fname,(int)file->mode,(int)file->rdev);
if (do_mknod(fname,file->mode,file->rdev) != 0) {
-
f
printf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose)
} else {
set_perms(fname,file,NULL,0);
if (verbose)
-
f
printf(FINFO,"%s\n",fname);
+
r
printf(FINFO,"%s\n",fname);
}
} else {
set_perms(fname,file,&st,1);
}
} else {
set_perms(fname,file,&st,1);
@@
-450,12
+451,12
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (preserve_hard_links && check_hard_link(file)) {
if (verbose > 1)
if (preserve_hard_links && check_hard_link(file)) {
if (verbose > 1)
-
f
printf(FINFO,"%s is a hard link\n",f_name(file));
+
r
printf(FINFO,"%s is a hard link\n",f_name(file));
return;
}
if (!S_ISREG(file->mode)) {
return;
}
if (!S_ISREG(file->mode)) {
-
f
printf(FINFO,"skipping non-regular file %s\n",fname);
+
r
printf(FINFO,"skipping non-regular file %s\n",fname);
return;
}
return;
}
@@
-465,7
+466,7
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (!dry_run) send_sums(NULL,f_out);
} else {
if (verbose > 1)
if (!dry_run) send_sums(NULL,f_out);
} else {
if (verbose > 1)
-
f
printf(FERROR,"recv_generator failed to open %s\n",fname);
+
r
printf(FERROR,"recv_generator failed to open %s\n",fname);
}
return;
}
}
return;
}
@@
-483,7
+484,7
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (update_only && st.st_mtime > file->modtime) {
if (verbose > 1)
if (update_only && st.st_mtime > file->modtime) {
if (verbose > 1)
-
f
printf(FINFO,"%s is newer\n",fname);
+
r
printf(FINFO,"%s is newer\n",fname);
return;
}
return;
}
@@
-507,8
+508,8
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
fd = open(fname,O_RDONLY);
if (fd == -1) {
fd = open(fname,O_RDONLY);
if (fd == -1) {
-
f
printf(FERROR,"failed to open %s : %s\n",fname,strerror(errno));
-
f
printf(FERROR,"skipping %s\n",fname);
+
r
printf(FERROR,"failed to open %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"skipping %s\n",fname);
return;
}
return;
}
@@
-519,12
+520,12
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
}
if (verbose > 3)
}
if (verbose > 3)
-
f
printf(FINFO,"gen mapped %s of size %d\n",fname,(int)st.st_size);
+
r
printf(FINFO,"gen mapped %s of size %d\n",fname,(int)st.st_size);
s = generate_sums(buf,st.st_size,adapt_block_size(file, block_size));
if (verbose > 2)
s = generate_sums(buf,st.st_size,adapt_block_size(file, block_size));
if (verbose > 2)
-
f
printf(FINFO,"sending sums for %d\n",i);
+
r
printf(FINFO,"sending sums for %d\n",i);
write_int(f_out,i);
send_sums(s,f_out);
write_int(f_out,i);
send_sums(s,f_out);
@@
-541,8
+542,8
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
{
int i,n,remainder,len,count;
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
{
int i,n,remainder,len,count;
-
off_t
offset = 0;
-
off_t
offset2;
+
OFF_T
offset = 0;
+
OFF_T
offset2;
char *data;
static char file_sum1[MD4_SUM_LENGTH];
static char file_sum2[MD4_SUM_LENGTH];
char *data;
static char file_sum1[MD4_SUM_LENGTH];
static char file_sum2[MD4_SUM_LENGTH];
@@
-557,12
+558,12
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
for (i=recv_token(f_in,&data); i != 0; i=recv_token(f_in,&data)) {
if (i > 0) {
if (verbose > 3)
for (i=recv_token(f_in,&data); i != 0; i=recv_token(f_in,&data)) {
if (i > 0) {
if (verbose > 3)
-
f
printf(FINFO,"data recv %d at %d\n",i,(int)offset);
+
r
printf(FINFO,"data recv %d at %d\n",i,(int)offset);
sum_update(data,i);
if (fd != -1 && write_file(fd,data,i) != i) {
sum_update(data,i);
if (fd != -1 && write_file(fd,data,i) != i) {
-
f
printf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
offset += i;
exit_cleanup(1);
}
offset += i;
@@
-574,7
+575,7
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
len = remainder;
if (verbose > 3)
len = remainder;
if (verbose > 3)
-
f
printf(FINFO,"chunk[%d] of size %d at %d offset=%d\n",
+
r
printf(FINFO,"chunk[%d] of size %d at %d offset=%d\n",
i,len,(int)offset2,(int)offset);
map = map_ptr(buf,offset2,len);
i,len,(int)offset2,(int)offset);
map = map_ptr(buf,offset2,len);
@@
-583,7
+584,7
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
sum_update(map,len);
if (fd != -1 && write_file(fd,map,len) != len) {
sum_update(map,len);
if (fd != -1 && write_file(fd,map,len) != len) {
-
f
printf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
offset += len;
exit_cleanup(1);
}
offset += len;
@@
-591,7
+592,7
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
}
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
}
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
-
f
printf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
+
r
printf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
exit_cleanup(1);
}
@@
-600,7
+601,7
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
if (remote_version >= 14) {
read_buf(f_in,file_sum2,MD4_SUM_LENGTH);
if (verbose > 2)
if (remote_version >= 14) {
read_buf(f_in,file_sum2,MD4_SUM_LENGTH);
if (verbose > 2)
-
f
printf(FINFO,"got file_sum\n");
+
r
printf(FINFO,"got file_sum\n");
if (fd != -1 && memcmp(file_sum1,file_sum2,MD4_SUM_LENGTH) != 0)
return 0;
}
if (fd != -1 && memcmp(file_sum1,file_sum2,MD4_SUM_LENGTH) != 0)
return 0;
}
@@
-612,16
+613,16
@@
static void delete_one(struct file_struct *f)
{
if (!S_ISDIR(f->mode)) {
if (do_unlink(f_name(f)) != 0) {
{
if (!S_ISDIR(f->mode)) {
if (do_unlink(f_name(f)) != 0) {
-
f
printf(FERROR,"unlink %s : %s\n",f_name(f),strerror(errno));
+
r
printf(FERROR,"unlink %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
} else if (verbose) {
-
f
printf(FINFO,"deleting %s\n",f_name(f));
+
r
printf(FINFO,"deleting %s\n",f_name(f));
}
} else {
if (do_rmdir(f_name(f)) != 0) {
if (errno != ENOTEMPTY && errno != EEXIST)
}
} else {
if (do_rmdir(f_name(f)) != 0) {
if (errno != ENOTEMPTY && errno != EEXIST)
-
f
printf(FERROR,"rmdir %s : %s\n",f_name(f),strerror(errno));
+
r
printf(FERROR,"rmdir %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
} else if (verbose) {
-
f
printf(FINFO,"deleting directory %s\n",f_name(f));
+
r
printf(FINFO,"deleting directory %s\n",f_name(f));
}
}
}
}
}
}
@@
-651,7
+652,7
@@
static void add_delete_entry(struct file_struct *file)
dlist_len++;
if (verbose > 3)
dlist_len++;
if (verbose > 3)
-
f
printf(FINFO,"added %s to delete list\n", f_name(file));
+
r
printf(FINFO,"added %s to delete list\n", f_name(file));
}
/* yuck! This function wouldn't have been necessary if I had the sorting
}
/* yuck! This function wouldn't have been necessary if I had the sorting
@@
-661,7
+662,7
@@
static void add_delete_entry(struct file_struct *file)
static int delete_already_done(struct file_list *flist,int j)
{
int i;
static int delete_already_done(struct file_list *flist,int j)
{
int i;
-
struct stat
st;
+
STRUCT_STAT
st;
if (link_stat(f_name(flist->files[j]), &st)) return 1;
if (link_stat(f_name(flist->files[j]), &st)) return 1;
@@
-688,7
+689,7
@@
static void delete_files(struct file_list *flist)
add_cvs_excludes();
if (io_error) {
add_cvs_excludes();
if (io_error) {
-
f
printf(FINFO,"IO error encountered - skipping file deletion\n");
+
r
printf(FINFO,"IO error encountered - skipping file deletion\n");
return;
}
return;
}
@@
-706,7
+707,7
@@
static void delete_files(struct file_list *flist)
}
if (verbose > 1)
}
if (verbose > 1)
-
f
printf(FINFO,"deleting in %s\n", name);
+
r
printf(FINFO,"deleting in %s\n", name);
for (i=local_file_list->count-1;i>=0;i--) {
if (!local_file_list->files[i]->basename) continue;
for (i=local_file_list->count-1;i>=0;i--) {
if (!local_file_list->files[i]->basename) continue;
@@
-743,7
+744,7
@@
void sig_int(void)
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
{
int fd1,fd2;
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
{
int fd1,fd2;
-
struct stat
st;
+
STRUCT_STAT
st;
char *fname;
char fnametmp[MAXPATHLEN];
struct map_struct *buf;
char *fname;
char fnametmp[MAXPATHLEN];
struct map_struct *buf;
@@
-753,7
+754,7
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
int recv_ok;
if (verbose > 2) {
int recv_ok;
if (verbose > 2) {
-
f
printf(FINFO,"recv_files(%d) starting\n",flist->count);
+
r
printf(FINFO,"recv_files(%d) starting\n",flist->count);
}
if (recurse && delete_mode && !local_name && flist->count>0) {
}
if (recurse && delete_mode && !local_name && flist->count>0) {
@@
-768,7
+769,7
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
phase++;
csum_length = SUM_LENGTH;
if (verbose > 2)
phase++;
csum_length = SUM_LENGTH;
if (verbose > 2)
-
f
printf(FINFO,"recv_files phase=%d\n",phase);
+
r
printf(FINFO,"recv_files phase=%d\n",phase);
write_int(f_gen,-1);
write_flush(f_gen);
continue;
write_int(f_gen,-1);
write_flush(f_gen);
continue;
@@
-789,20
+790,20
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
}
if (verbose > 2)
}
if (verbose > 2)
-
f
printf(FINFO,"recv_files(%s)\n",fname);
+
r
printf(FINFO,"recv_files(%s)\n",fname);
/* open the file */
fd1 = open(fname,O_RDONLY);
/* open the file */
fd1 = open(fname,O_RDONLY);
- if (fd1 != -1 && fstat(fd1,&st) != 0) {
-
f
printf(FERROR,"fstat %s : %s\n",fname,strerror(errno));
+ if (fd1 != -1 &&
do_
fstat(fd1,&st) != 0) {
+
r
printf(FERROR,"fstat %s : %s\n",fname,strerror(errno));
receive_data(f_in,NULL,-1,NULL);
close(fd1);
continue;
}
if (fd1 != -1 && !S_ISREG(st.st_mode)) {
receive_data(f_in,NULL,-1,NULL);
close(fd1);
continue;
}
if (fd1 != -1 && !S_ISREG(st.st_mode)) {
-
f
printf(FERROR,"%s : not a regular file (recv_files)\n",fname);
+
r
printf(FERROR,"%s : not a regular file (recv_files)\n",fname);
receive_data(f_in,NULL,-1,NULL);
close(fd1);
continue;
receive_data(f_in,NULL,-1,NULL);
close(fd1);
continue;
@@
-811,14
+812,14
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if (fd1 != -1 && st.st_size > 0) {
buf = map_file(fd1,st.st_size);
if (verbose > 2)
if (fd1 != -1 && st.st_size > 0) {
buf = map_file(fd1,st.st_size);
if (verbose > 2)
-
f
printf(FINFO,"recv mapped %s of size %d\n",fname,(int)st.st_size);
+
r
printf(FINFO,"recv mapped %s of size %d\n",fname,(int)st.st_size);
} else {
buf = NULL;
}
/* open tmp file */
if (strlen(fname) > (MAXPATHLEN-8)) {
} else {
buf = NULL;
}
/* open tmp file */
if (strlen(fname) > (MAXPATHLEN-8)) {
-
f
printf(FERROR,"filename too long\n");
+
r
printf(FERROR,"filename too long\n");
if (buf) unmap_file(buf);
close(fd1);
continue;
if (buf) unmap_file(buf);
close(fd1);
continue;
@@
-835,7
+836,7
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
sprintf(fnametmp,"%s.XXXXXX",fname);
}
if (NULL == do_mktemp(fnametmp)) {
sprintf(fnametmp,"%s.XXXXXX",fname);
}
if (NULL == do_mktemp(fnametmp)) {
-
f
printf(FERROR,"mktemp %s failed\n",fnametmp);
+
r
printf(FERROR,"mktemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL);
if (buf) unmap_file(buf);
close(fd1);
receive_data(f_in,buf,-1,NULL);
if (buf) unmap_file(buf);
close(fd1);
@@
-847,7
+848,7
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
fd2 = do_open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,file->mode);
}
if (fd2 == -1) {
fd2 = do_open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,file->mode);
}
if (fd2 == -1) {
-
f
printf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
+
r
printf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
receive_data(f_in,buf,-1,NULL);
if (buf) unmap_file(buf);
close(fd1);
receive_data(f_in,buf,-1,NULL);
if (buf) unmap_file(buf);
close(fd1);
@@
-869,17
+870,17
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
close(fd2);
if (verbose > 2)
close(fd2);
if (verbose > 2)
-
f
printf(FINFO,"renaming %s to %s\n",fnametmp,fname);
+
r
printf(FINFO,"renaming %s to %s\n",fnametmp,fname);
if (make_backups) {
char fnamebak[MAXPATHLEN];
if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
if (make_backups) {
char fnamebak[MAXPATHLEN];
if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
-
f
printf(FERROR,"backup filename too long\n");
+
r
printf(FERROR,"backup filename too long\n");
continue;
}
sprintf(fnamebak,"%s%s",fname,backup_suffix);
if (do_rename(fname,fnamebak) != 0 && errno != ENOENT) {
continue;
}
sprintf(fnamebak,"%s%s",fname,backup_suffix);
if (do_rename(fname,fnamebak) != 0 && errno != ENOENT) {
-
f
printf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
+
r
printf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
continue;
}
}
continue;
}
}
@@
-890,14
+891,14
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
/* rename failed on cross-filesystem link.
Copy the file instead. */
if (copy_file(fnametmp,fname, file->mode)) {
/* rename failed on cross-filesystem link.
Copy the file instead. */
if (copy_file(fnametmp,fname, file->mode)) {
-
f
printf(FERROR,"copy %s -> %s : %s\n",
+
r
printf(FERROR,"copy %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
}
do_unlink(fnametmp);
} else {
fnametmp,fname,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
}
do_unlink(fnametmp);
} else {
-
f
printf(FERROR,"rename %s -> %s : %s\n",
+
r
printf(FERROR,"rename %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
do_unlink(fnametmp);
}
fnametmp,fname,strerror(errno));
do_unlink(fnametmp);
}
@@
-910,11
+911,11
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if (!recv_ok) {
if (csum_length == SUM_LENGTH) {
if (!recv_ok) {
if (csum_length == SUM_LENGTH) {
-
f
printf(FERROR,"ERROR: file corruption in %s. File changed during transfer?\n",
+
r
printf(FERROR,"ERROR: file corruption in %s. File changed during transfer?\n",
fname);
} else {
if (verbose > 1)
fname);
} else {
if (verbose > 1)
-
f
printf(FINFO,"redoing %s(%d)\n",fname,i);
+
r
printf(FINFO,"redoing %s(%d)\n",fname,i);
write_int(f_gen,i);
}
}
write_int(f_gen,i);
}
}
@@
-932,7
+933,7
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
}
if (verbose > 2)
}
if (verbose > 2)
-
f
printf(FINFO,"recv_files finished\n");
+
r
printf(FINFO,"recv_files finished\n");
return 0;
}
return 0;
}
@@
-944,7
+945,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
int fd;
struct sum_struct *s;
struct map_struct *buf;
int fd;
struct sum_struct *s;
struct map_struct *buf;
-
struct stat
st;
+
STRUCT_STAT
st;
char fname[MAXPATHLEN];
int i;
struct file_struct *file;
char fname[MAXPATHLEN];
int i;
struct file_struct *file;
@@
-952,7
+953,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
int offset=0;
if (verbose > 2)
int offset=0;
if (verbose > 2)
-
f
printf(FINFO,"send_files starting\n");
+
r
printf(FINFO,"send_files starting\n");
setup_nonblocking(f_in,f_out);
setup_nonblocking(f_in,f_out);
@@
-965,7
+966,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
write_int(f_out,-1);
write_flush(f_out);
if (verbose > 2)
write_int(f_out,-1);
write_flush(f_out);
if (verbose > 2)
-
f
printf(FINFO,"send_files phase=%d\n",phase);
+
r
printf(FINFO,"send_files phase=%d\n",phase);
continue;
}
break;
continue;
}
break;
@@
-979,7
+980,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
fname[MAXPATHLEN-1] = 0;
if (strlen(fname) == MAXPATHLEN-1) {
io_error = 1;
fname[MAXPATHLEN-1] = 0;
if (strlen(fname) == MAXPATHLEN-1) {
io_error = 1;
-
f
printf(FERROR, "send_files failed on long-named directory %s\n",
+
r
printf(FERROR, "send_files failed on long-named directory %s\n",
fname);
return;
}
fname);
return;
}
@@
-989,7
+990,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
strncat(fname,f_name(file),MAXPATHLEN-strlen(fname));
if (verbose > 2)
strncat(fname,f_name(file),MAXPATHLEN-strlen(fname));
if (verbose > 2)
-
f
printf(FINFO,"send_files(%d,%s)\n",i,fname);
+
r
printf(FINFO,"send_files(%d,%s)\n",i,fname);
if (dry_run) {
if (!am_server && verbose)
if (dry_run) {
if (!am_server && verbose)
@@
-1001,23
+1002,23
@@
void send_files(struct file_list *flist,int f_out,int f_in)
s = receive_sums(f_in);
if (!s) {
io_error = 1;
s = receive_sums(f_in);
if (!s) {
io_error = 1;
-
f
printf(FERROR,"receive_sums failed\n");
+
r
printf(FERROR,"receive_sums failed\n");
return;
}
fd = open(fname,O_RDONLY);
if (fd == -1) {
io_error = 1;
return;
}
fd = open(fname,O_RDONLY);
if (fd == -1) {
io_error = 1;
-
f
printf(FERROR,"send_files failed to open %s: %s\n",
+
r
printf(FERROR,"send_files failed to open %s: %s\n",
fname,strerror(errno));
free_sums(s);
continue;
}
/* map the local file */
fname,strerror(errno));
free_sums(s);
continue;
}
/* map the local file */
- if (fstat(fd,&st) != 0) {
+ if (
do_
fstat(fd,&st) != 0) {
io_error = 1;
io_error = 1;
-
f
printf(FERROR,"fstat failed : %s\n",strerror(errno));
+
r
printf(FERROR,"fstat failed : %s\n",strerror(errno));
free_sums(s);
close(fd);
return;
free_sums(s);
close(fd);
return;
@@
-1030,7
+1031,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
}
if (verbose > 2)
}
if (verbose > 2)
-
f
printf(FINFO,"send_files mapped %s of size %d\n",
+
r
printf(FINFO,"send_files mapped %s of size %d\n",
fname,(int)st.st_size);
write_int(f_out,i);
fname,(int)st.st_size);
write_int(f_out,i);
@@
-1040,7
+1041,7
@@
void send_files(struct file_list *flist,int f_out,int f_in)
write_int(f_out,s->remainder);
if (verbose > 2)
write_int(f_out,s->remainder);
if (verbose > 2)
-
f
printf(FINFO,"calling match_sums %s\n",fname);
+
r
printf(FINFO,"calling match_sums %s\n",fname);
if (!am_server && verbose)
printf("%s\n",fname+offset);
if (!am_server && verbose)
printf("%s\n",fname+offset);
@@
-1054,11
+1055,11
@@
void send_files(struct file_list *flist,int f_out,int f_in)
free_sums(s);
if (verbose > 2)
free_sums(s);
if (verbose > 2)
-
f
printf(FINFO,"sender finished %s\n",fname);
+
r
printf(FINFO,"sender finished %s\n",fname);
}
if (verbose > 2)
}
if (verbose > 2)
-
f
printf(FINFO,"send files finished\n");
+
r
printf(FINFO,"send files finished\n");
match_report();
match_report();
@@
-1074,7
+1075,7
@@
void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
int phase=0;
if (verbose > 2)
int phase=0;
if (verbose > 2)
-
f
printf(FINFO,"generator starting pid=%d count=%d\n",
+
r
printf(FINFO,"generator starting pid=%d count=%d\n",
(int)getpid(),flist->count);
for (i = 0; i < flist->count; i++) {
(int)getpid(),flist->count);
for (i = 0; i < flist->count; i++) {
@@
-1100,7
+1101,7
@@
void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
ignore_times=1;
if (verbose > 2)
ignore_times=1;
if (verbose > 2)
-
f
printf(FINFO,"generate_files phase=%d\n",phase);
+
r
printf(FINFO,"generate_files phase=%d\n",phase);
write_int(f,-1);
write_flush(f);
write_int(f,-1);
write_flush(f);
@@
-1120,7
+1121,7
@@
void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
phase++;
if (verbose > 2)
phase++;
if (verbose > 2)
-
f
printf(FINFO,"generate_files phase=%d\n",phase);
+
r
printf(FINFO,"generate_files phase=%d\n",phase);
write_int(f,-1);
write_flush(f);
write_int(f,-1);
write_flush(f);
@@
-1128,7
+1129,7
@@
void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
if (verbose > 2)
if (verbose > 2)
-
f
printf(FINFO,"generator wrote %ld\n",(long)write_total());
+
r
printf(FINFO,"generator wrote %ld\n",(long)write_total());
}
}