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
added chmod() and chown() to syscall.c
[rsync/rsync.git]
/
rsync.c
diff --git
a/rsync.c
b/rsync.c
index
e9b5e3f
..
4560455
100644
(file)
--- a/
rsync.c
+++ b/
rsync.c
@@
-223,7
+223,7
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
if (preserve_perms && !S_ISLNK(st->st_mode) &&
st->st_mode != file->mode) {
updated = 1;
if (preserve_perms && !S_ISLNK(st->st_mode) &&
st->st_mode != file->mode) {
updated = 1;
- if (chmod(fname,file->mode) != 0) {
+ if (
do_
chmod(fname,file->mode) != 0) {
fprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
return 0;
fprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
return 0;
@@
-234,7
+234,7
@@
static int set_perms(char *fname,struct file_struct *file,struct stat *st,
if ((am_root && preserve_uid && st->st_uid != file->uid) ||
(preserve_gid && st->st_gid != file->gid)) {
updated = 1;
if ((am_root && preserve_uid && st->st_uid != file->uid) ||
(preserve_gid && st->st_gid != file->gid)) {
updated = 1;
- if (lchown(fname,
+ if (
do_
lchown(fname,
(am_root&&preserve_uid)?file->uid:-1,
preserve_gid?file->gid:-1) != 0) {
if (verbose>1 || preserve_uid)
(am_root&&preserve_uid)?file->uid:-1,
preserve_gid?file->gid:-1) != 0) {
if (verbose>1 || preserve_uid)
@@
-304,7
+304,7
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (S_ISDIR(file->mode)) {
if (dry_run) return;
if (statret == 0 && !S_ISDIR(st.st_mode)) {
if (S_ISDIR(file->mode)) {
if (dry_run) return;
if (statret == 0 && !S_ISDIR(st.st_mode)) {
- if (unlink(fname) != 0) {
+ if (
do_
unlink(fname) != 0) {
fprintf(FERROR,"unlink %s : %s\n",fname,strerror(errno));
return;
}
fprintf(FERROR,"unlink %s : %s\n",fname,strerror(errno));
return;
}
@@
-337,8
+337,8
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
}
}
}
}
}
}
-
if (!dry_run)
unlink(fname);
- if (
!dry_run &&
symlink(file->link,fname) != 0) {
+
do_
unlink(fname);
+ if (
do_
symlink(file->link,fname) != 0) {
fprintf(FERROR,"link %s -> %s : %s\n",
fname,file->link,strerror(errno));
} else {
fprintf(FERROR,"link %s -> %s : %s\n",
fname,file->link,strerror(errno));
} else {
@@
-356,12
+356,11
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (statret != 0 ||
st.st_mode != file->mode ||
st.st_rdev != file->rdev) {
if (statret != 0 ||
st.st_mode != file->mode ||
st.st_rdev != file->rdev) {
-
if (!dry_run)
unlink(fname);
+
do_
unlink(fname);
if (verbose > 2)
fprintf(FERROR,"mknod(%s,0%o,0x%x)\n",
fname,(int)file->mode,(int)file->rdev);
if (verbose > 2)
fprintf(FERROR,"mknod(%s,0%o,0x%x)\n",
fname,(int)file->mode,(int)file->rdev);
- if (!dry_run &&
- mknod(fname,file->mode,file->rdev) != 0) {
+ if (do_mknod(fname,file->mode,file->rdev) != 0) {
fprintf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
fprintf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
@@
-405,7
+404,7
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
fprintf(FERROR,"ERROR: %s is a directory\n",fname);
return;
}
fprintf(FERROR,"ERROR: %s is a directory\n",fname);
return;
}
- if (unlink(fname) != 0) {
+ if (
do_
unlink(fname) != 0) {
fprintf(FERROR,"%s : not a regular file (generator)\n",fname);
return;
}
fprintf(FERROR,"%s : not a regular file (generator)\n",fname);
return;
}
@@
-546,13
+545,13
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
static void delete_one(struct file_struct *f)
{
if (!S_ISDIR(f->mode)) {
static void delete_one(struct file_struct *f)
{
if (!S_ISDIR(f->mode)) {
- if (
!dry_run &&
unlink(f_name(f)) != 0) {
+ if (
do_
unlink(f_name(f)) != 0) {
fprintf(FERROR,"unlink %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
fprintf(FERROR,"deleting %s\n",f_name(f));
}
} else {
fprintf(FERROR,"unlink %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
fprintf(FERROR,"deleting %s\n",f_name(f));
}
} else {
- if (
!dry_run &&
rmdir(f_name(f)) != 0) {
+ if (
do_
rmdir(f_name(f)) != 0) {
if (errno != ENOTEMPTY)
fprintf(FERROR,"rmdir %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
if (errno != ENOTEMPTY)
fprintf(FERROR,"rmdir %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
@@
-651,12
+650,12
@@
static void delete_files(struct file_list *flist)
}
}
}
}
-static char *cleanup_fname
= NULL
;
+static char *cleanup_fname;
void exit_cleanup(int code)
{
if (cleanup_fname)
void exit_cleanup(int code)
{
if (cleanup_fname)
- unlink(cleanup_fname);
+
do_
unlink(cleanup_fname);
signal(SIGUSR1, SIG_IGN);
if (code) {
kill_all(SIGUSR1);
signal(SIGUSR1, SIG_IGN);
if (code) {
kill_all(SIGUSR1);
@@
-771,10
+770,10
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
close(fd1);
continue;
}
close(fd1);
continue;
}
- fd2 = open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,file->mode);
+ fd2 =
do_
open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,file->mode);
if (fd2 == -1 && relative_paths && errno == ENOENT &&
create_directory_path(fnametmp) == 0) {
if (fd2 == -1 && relative_paths && errno == ENOENT &&
create_directory_path(fnametmp) == 0) {
- fd2 = open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,file->mode);
+ fd2 =
do_
open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,file->mode);
}
if (fd2 == -1) {
fprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
}
if (fd2 == -1) {
fprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
@@
-825,11
+824,11
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
} else {
set_perms(fname,file,NULL,0);
}
} else {
set_perms(fname,file,NULL,0);
}
- unlink(fnametmp);
+
do_
unlink(fnametmp);
} else {
fprintf(FERROR,"rename %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
} else {
fprintf(FERROR,"rename %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
- unlink(fnametmp);
+
do_
unlink(fnametmp);
}
} else {
set_perms(fname,file,NULL,0);
}
} else {
set_perms(fname,file,NULL,0);
@@
-936,12
+935,14
@@
off_t send_files(struct file_list *flist,int f_out,int f_in)
if (fd == -1) {
fprintf(FERROR,"send_files failed to open %s: %s\n",
fname,strerror(errno));
if (fd == -1) {
fprintf(FERROR,"send_files failed to open %s: %s\n",
fname,strerror(errno));
+ free_sums(s);
continue;
}
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
continue;
}
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
+ free_sums(s);
close(fd);
return -1;
}
close(fd);
return -1;
}
@@
-1051,7
+1052,7
@@
void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
if (verbose > 2)
if (verbose > 2)
- fprintf(FERROR,"generator wrote %
d\n",
write_total());
+ fprintf(FERROR,"generator wrote %
ld\n",(long)
write_total());
}
}